<?xml-stylesheet type="text/xsl" href="../styles/pmathml.xsl"?>
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dsi="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xml:space="preserve"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"/><title>D02NGF : NAG Library, Mark 22</title><link rel="stylesheet" href="../styles/libdoc.css" type="text/css"/><script type="text/javascript">
   function showLevel(_levelId){
    var thisLevel = document.getElementById(_levelId);
    var thisplus = document.getElementById( _levelId.concat('plus'));
    var thisminus = document.getElementById( _levelId.concat('minus'));
    if(thisLevel.style.display != "block"){
     thisLevel.style.display = "block";
     thisplus.style.display = "none";
     thisminus.style.display = "inline";
     }
    else{
     thisLevel.style.display = "none";
     thisminus.style.display = "none";
     thisplus.style.display = "inline";
     }
    }
  </script></head><body><hr/><div><a class="rout" href="../../pdf/D02/d02ngf.pdf">D02NGF (PDF version)</a></div><div><a class="chap" href="d02conts.xml">D02 Chapter Contents</a></div><div><a class="chapint" href="d02intro.xml">D02 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div><hr/><h1 class="libdoc">NAG Library Routine Document<br/><br/>D02NGF</h1><div class="paramtext"><div class="header"><b>Note:</b>&#160; before using this routine, please read the Users' Note for your implementation to check the interpretation of <span class="bitalic">bold italicised</span> terms and other implementation-dependent details.</div></div> 
<div class="htmltoc">
<h2 class="htmltoc"><span class="htmltochead" onclick="showLevel('htmltoc');"><span class="htmltocplus" id="htmltocplus">+</span><span class="htmltocminus" id="htmltocminus">&#8722;</span></span>&#160;Contents</h2>
<div class="htmltocitem" id="htmltoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#purpose">1&#160;&#160;<b>Purpose</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#specification">2&#160;&#160;<b>Specification</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#description">3&#160;&#160;<b>Description</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">4&#160;&#160;<b>References</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#parameters">5&#160;&#160;<b>Parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#errors">6&#160;&#160;<b>Error Indicators and Warnings</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#accuracy">7&#160;&#160;<b>Accuracy</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments">8&#160;&#160;<b>Further Comments</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocexample');"><span class="htmltocplus" id="tocexampleplus">+</span><span class="htmltocminus" id="tocexampleminus">&#8722;</span></span>
<a class="htmltoc" href="#example">9&#160;&#160;<b>Example</b></a>
<div class="htmltocitem" id="tocexample">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examtext">9.1&#160;&#160;<b>Program Text</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examdata">9.2&#160;&#160;<b>Program Data</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examresults">9.3&#160;&#160;<b>Program Results</b></a>
</div>
</div>
</div>
</div>
</div><h2 class="standard"><a class="sec" name="purpose" id="purpose"/>1&#160;&#160;Purpose</h2>
<div class="paramtext">D02NGF is a forward communication routine for integrating stiff systems of implicit ordinary differential equations coupled with algebraic equations when the Jacobian is a full matrix.</div><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;D02NGF&#160;(</td><td class="tdfspec2"><a class="arg" href="#NEQ">NEQ</a>, <a class="arg" href="#LDYSAV">LDYSAV</a>, <a class="arg" href="#T">T</a>, <a class="arg" href="#TOUT">TOUT</a>, <a class="arg" href="#Y">Y</a>, <a class="arg" href="#YDOT">YDOT</a>, <a class="arg" href="#RWORK">RWORK</a>, <a class="arg" href="#RTOL">RTOL</a>, <a class="arg" href="#ATOL">ATOL</a>, <a class="arg" href="#ITOL">ITOL</a>, <a class="arg" href="#INFORM">INFORM</a>, <a class="arg" href="#RESID">RESID</a>, <a class="arg" href="#YSAV">YSAV</a>, <a class="arg" href="#SDYSAV">SDYSAV</a>, <a class="arg" href="#JAC">JAC</a>, <a class="arg" href="#WKJAC">WKJAC</a>, <a class="arg" href="#NWKJAC">NWKJAC</a>, <a class="arg" href="#MONITR">MONITR</a>, <a class="arg" href="#LDERIV">LDERIV</a>, <a class="arg" href="#ITASK">ITASK</a>, <a class="arg" href="#ITRACE">ITRACE</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NEQ, LDYSAV, ITOL, INFORM(23), SDYSAV, NWKJAC, ITASK, ITRACE, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">T, TOUT, Y(NEQ), YDOT(NEQ), RWORK(50+4*NEQ), RTOL(*), ATOL(*), YSAV(LDYSAV,SDYSAV), WKJAC(NWKJAC)</td></tr><tr><td class="tdfspec1">LOGICAL</td><td class="tdfspec2">LDERIV(2)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">RESID, JAC, MONITR</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02NGF is a general purpose routine for integrating the initial value problem for a stiff system of implicit ordinary differential equations coupled with algebraic equations, written in the form

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>A</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>=</m:mo><m:mi>g</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

It is designed specifically for the case where the resulting Jacobian is a full matrix (see the description of <a class="arg" href="#JAC">JAC</a>).</div><div class="paramtext">Both interval and step oriented modes of operation are available and also modes designed to permit intermediate output within an interval oriented mode.</div><div class="paramtext">An outline of a typical calling program for D02NGF is given below.  It calls the full matrix linear algebra setup routine <a class="rout" href="../D02/d02nsf.xml">D02NSF</a>, the Backward Differentiation Formula (BDF)  integrator setup routine <a class="rout" href="../D02/d02nvf.xml">D02NVF</a>, and its diagnostic counterpart <a class="rout" href="../D02/d02nyf.xml">D02NYF</a>.
<pre class="verbatim">
C
C     declarations
C
      EXTERNAL RESID, JAC, MONITR
          .
          .
          .
      IFAIL = 0
      CALL D02NVF(...,IFAIL)
      CALL D02NSF(NEQ, NEQMAX, JCEVAL, NWKJAC, RWORK, IFAIL)
      IFAIL = -1
      CALL D02NGF(NEQ, NEQMAX, T, TOUT, Y, YDOT, RWORK, RTOL,
     + ATOL, ITOL, INFORM, RESID, YSAVE, NY2DIM, JAC, WKJAC,
     + NWKJAC, MONITR, LDERIV, ITASK, ITRACE, IFAIL)
      IF (IFAIL.EQ.1 .OR. IFAIL.GE.14) STOP
      IFAIL = 0
      CALL D02NYF(...)
          .
          .
          .
      STOP
      END
</pre>

The linear algebra setup routine <a class="rout" href="../D02/d02nsf.xml">D02NSF</a> and one of the integrator setup routines, <a class="rout" href="../D02/d02mvf.xml">D02MVF</a>, <a class="rout" href="../D02/d02nvf.xml">D02NVF</a> or <a class="rout" href="../D02/d02nwf.xml">D02NWF</a>, must be called prior to the call of D02NGF.  The integrator diagnostic routine <a class="rout" href="../D02/d02nyf.xml">D02NYF</a> may be called after the call to D02NGF.  There is also a routine, <a class="rout" href="../D02/d02nzf.xml">D02NZF</a>, designed to permit you to change step size on a continuation call to D02NGF without restarting the integration process.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2>
<div class="paramtext">See the <a class="chapint" href="../D02/d02mnintro.xml">D02M&#8211;N sub-chapter Introduction</a>.</div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="NEQ" id="NEQ"/>1: &#160;&#160;&#8194; NEQ &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 


the number of differential equations to be solved.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="LDYSAV" id="LDYSAV"/>2: &#160;&#160;&#8194; LDYSAV &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 


a bound on the maximum number of equations to be solved during the integration.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDYSAV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDYSAV</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="T" id="T"/>3: &#160;&#160;&#8194; T &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mi>t</m:mi></m:math>, the value of the independent variable. The input value of <a class="arg" href="#T">T</a> is used only on the first call as the initial point of the integration.</div><div class="paramtext"><i>On exit</i>: the value at which the computed solution <m:math><m:mi>y</m:mi></m:math>&#160;is returned (usually at <a class="arg" href="#TOUT">TOUT</a>).</div></dd><dt class="paramhead"><a name="TOUT" id="TOUT"/>4: &#160;&#160;&#8194; TOUT &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 
the next value of <m:math><m:mi>t</m:mi></m:math>&#160;at which a computed solution is desired. For the initial <m:math><m:mi>t</m:mi></m:math>, the input value of <a class="arg" href="#TOUT">TOUT</a> is used to determine the direction of integration. Integration is permitted in either direction (see also <a class="arg" href="#ITASK">ITASK</a>).
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOUT"><m:mi mathcolor="#EE0000" mathvariant="bold">TOUT</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#T"><m:mi mathcolor="#EE0000" mathvariant="bold">T</m:mi></m:maction></m:math>.
</div>
<div class="paramtext"><i>On exit</i>: 
normally unchanged. However, when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math>, then <a class="arg" href="#TOUT">TOUT</a> contains the value of <a class="arg" href="#T">T</a> at which initial values have been computed without performing any integration. See descriptions of <a class="arg" href="#ITASK">ITASK</a> and <a class="arg" href="#LDERIV">LDERIV</a>.

</div></dd><dt class="paramhead"><a name="Y" id="Y"/>5: &#160;&#160;&#8194; Y(<a class="arg" href="#NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the values of the dependent variables (solution). On the first call the first <a class="arg" href="#NEQ">NEQ</a> elements of <m:math><m:mi>y</m:mi></m:math>&#160;must contain the vector of initial values.</div><div class="paramtext"><i>On exit</i>: the computed solution vector, evaluated at <m:math><m:mi>t</m:mi></m:math>&#160;(usually <m:math><m:mi>t</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOUT"><m:mi mathcolor="#EE0000" mathvariant="bold">TOUT</m:mi></m:maction></m:math>).</div></dd><dt class="paramhead"><a name="YDOT" id="YDOT"/>6: &#160;&#160;&#8194; YDOT(<a class="arg" href="#NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: if <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>, <a class="arg" href="#YDOT">YDOT</a> must contain approximations to the time derivatives <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;of the vector <m:math><m:mi>y</m:mi></m:math>.
<div class="paramtext">If <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>, <a class="arg" href="#YDOT">YDOT</a> need not be set on entry.</div>
</div>
<div class="paramtext"><i>On exit</i>: the time derivatives <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;of the vector <m:math><m:mi>y</m:mi></m:math>&#160;at the last integration point.</div></dd><dt class="paramhead"><a name="RWORK" id="RWORK"/>7: &#160;&#160;&#8194; RWORK(<m:math><m:mn>50</m:mn><m:mo>+</m:mo><m:mn>4</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Communication Array</span></dt><dt class="paramhead"><a name="RTOL" id="RTOL"/>8: &#160;&#160;&#8194; RTOL(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#RTOL">RTOL</a>
must be at least
<m:math><m:mn>1</m:mn></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ITOL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ITOL</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>, and at least <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>&#160;otherwise.</div>
<div class="paramtext"><i>On entry</i>: the relative local error tolerance.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#RTOL"><m:mi mathcolor="#EE0000" mathvariant="bold">RTOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#8805;</m:mo><m:mn>0.0</m:mn></m:math>&#160;for all relevant <m:math><m:mi>i</m:mi></m:math>&#160;(see <a class="arg" href="#ITOL">ITOL</a>).</div></dd><dt class="paramhead"><a name="ATOL" id="ATOL"/>9: &#160;&#160;&#8194; ATOL(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#ATOL">ATOL</a>
must be at least
<m:math><m:mn>1</m:mn></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ITOL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ITOL</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>, and at least <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>&#160;otherwise.</div>
<div class="paramtext"><i>On entry</i>: the absolute local error tolerance.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#ATOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ATOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#8805;</m:mo><m:mn>0.0</m:mn></m:math>&#160;for all relevant <m:math><m:mi>i</m:mi></m:math>&#160;(see <a class="arg" href="#ITOL">ITOL</a>)</div></dd><dt class="paramhead"><a name="ITOL" id="ITOL"/>10: &#8194; ITOL &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: a value to indicate the form of the local error test. <a class="arg" href="#ITOL">ITOL</a> indicates to D02NGF whether to interpret either or both of <a class="arg" href="#RTOL">RTOL</a> or <a class="arg" href="#ATOL">ATOL</a> as a vector or a scalar. The error test to be satisfied is <m:math><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub><m:mo>/</m:mo><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:mfenced><m:mo>&lt;</m:mo><m:mn>1.0</m:mn></m:math>, where <m:math><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;is defined as follows:

<div class="tablediv"><table class="frame-none"><tbody>
<tr>
<td class="libdoc" valign="top" align="center"><a class="arg" href="#ITOL">ITOL</a></td>
<td class="libdoc" valign="top" align="left"><a class="arg" href="#RTOL">RTOL</a></td>
<td class="libdoc" valign="top" align="left"><a class="arg" href="#ATOL">ATOL</a></td>
<td class="libdoc" valign="top" align="center"><m:math><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:math></td>
</tr><tr>
<td class="libdoc" valign="top" align="center">1</td>
<td class="libdoc" valign="top" align="left">scalar</td>
<td class="libdoc" valign="top" align="left">scalar</td>
<td class="libdoc" valign="top" align="left"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#RTOL"><m:mi mathcolor="#EE0000" mathvariant="bold">RTOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced><m:mo>+</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#ATOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ATOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math></td>
</tr><tr>
<td class="libdoc" valign="top" align="center">2</td>
<td class="libdoc" valign="top" align="left">scalar</td>
<td class="libdoc" valign="top" align="left">vector</td>
<td class="libdoc" valign="top" align="left"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#RTOL"><m:mi mathcolor="#EE0000" mathvariant="bold">RTOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced><m:mo>+</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#ATOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ATOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math></td>
</tr><tr>
<td class="libdoc" valign="top" align="center">3</td>
<td class="libdoc" valign="top" align="left">vector</td>
<td class="libdoc" valign="top" align="left">scalar</td>
<td class="libdoc" valign="top" align="left"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#RTOL"><m:mi mathcolor="#EE0000" mathvariant="bold">RTOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced><m:mo>+</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#ATOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ATOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math></td>
</tr><tr>
<td class="libdoc" valign="top" align="center">4</td>
<td class="libdoc" valign="top" align="left">vector</td>
<td class="libdoc" valign="top" align="left">vector</td>
<td class="libdoc" valign="top" align="left"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#RTOL"><m:mi mathcolor="#EE0000" mathvariant="bold">RTOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced><m:mo>+</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#ATOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ATOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math></td>
</tr>
</tbody>
</table></div><div class="paramtext"><m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;is an estimate of the local error in <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, computed internally, and the choice of norm to be used is defined by a previous call to an integrator setup routine.</div>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ITOL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>, <m:math><m:mn>2</m:mn></m:math>, <m:math><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="INFORM" id="INFORM"/>11: &#8194; INFORM(<m:math><m:mn>23</m:mn></m:math>) &#8211; INTEGER array<span class="pclass">Communication Array</span></dt><dt class="paramhead"><a name="RESID" id="RESID"/>12: &#8194; RESID &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#RESID">RESID</a> must evaluate the residual

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>r</m:mi><m:mo>=</m:mo><m:mi>g</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>-</m:mo><m:mi>A</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup>
</m:math></td><td class="formula2"/></tr></table></div>

in one case and

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>r</m:mi><m:mo>=</m:mo><m:mo>-</m:mo><m:mi>A</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup>
</m:math></td><td class="formula2"/></tr></table></div>

in another.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#RESID">RESID</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;RESID&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02ngf.xml#RESID_NEQ">NEQ</a>, <a class="arg" href="../D02/d02ngf.xml#RESID_T">T</a>, <a class="arg" href="../D02/d02ngf.xml#RESID_Y">Y</a>, <a class="arg" href="../D02/d02ngf.xml#RESID_YDOT">YDOT</a>, <a class="arg" href="../D02/d02ngf.xml#RESID_R">R</a>, <a class="arg" href="../D02/d02ngf.xml#RESID_IRES">IRES</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NEQ, IRES</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">T, Y(NEQ), YDOT(NEQ), R(NEQ)</td></tr></table>
<dl><dt class="paramhead"><a name="RESID_NEQ" id="RESID_NEQ"/>1: &#160;&#160;&#8194; NEQ &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 

the number of equations being solved.</div></dd><dt class="paramhead"><a name="RESID_T" id="RESID_T"/>2: &#160;&#160;&#8194; T &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mi>t</m:mi></m:math>, the current value of the independent variable.</div></dd><dt class="paramhead"><a name="RESID_Y" id="RESID_Y"/>3: &#160;&#160;&#8194; Y(<a class="arg" href="../D02/d02ngf.xml#RESID_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the value of <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>.</div></dd><dt class="paramhead"><a name="RESID_YDOT" id="RESID_YDOT"/>4: &#160;&#160;&#8194; YDOT(<a class="arg" href="../D02/d02ngf.xml#RESID_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the value of <m:math><m:msubsup><m:mi>y</m:mi><m:mi>i</m:mi><m:mo>&#8242;</m:mo></m:msubsup></m:math>&#160;at <m:math><m:mi>t</m:mi></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>.</div></dd><dt class="paramhead"><a name="RESID_R" id="RESID_R"/>5: &#160;&#160;&#8194; R(<a class="arg" href="../D02/d02ngf.xml#RESID_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_R"><m:mi mathcolor="#EE0000" mathvariant="bold">R</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;must contain the <m:math><m:mi>i</m:mi></m:math>th component of <m:math><m:mi>r</m:mi></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>, where 
<div class="formula-eqn"><a name="eqn1" id="eqn1"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block"> <m:mi>r</m:mi><m:mo>=</m:mo><m:mi>g</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>-</m:mo><m:mi>A</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup> </m:math></td><td class="formula-eqn2">
      (1)
     </td></tr></table></div>
 or 
<div class="formula-eqn"><a name="eqn2" id="eqn2"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block"> <m:mi>r</m:mi><m:mo>=</m:mo><m:mo>-</m:mo><m:mi>A</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup> </m:math></td><td class="formula-eqn2">
      (2)
     </td></tr></table></div>
 and where the definition of <m:math><m:mi>r</m:mi></m:math>&#160;is determined by the input value of <a class="arg" href="../D02/d02ngf.xml#RESID_IRES">IRES</a>.</div></dd><dt class="paramhead"><a name="RESID_IRES" id="RESID_IRES"/>6: &#160;&#160;&#8194; IRES &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the form of the residual that must be returned in array <a class="arg" href="../D02/d02ngf.xml#RESID_R">R</a>. 

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math></dt>
<dd>The residual defined in equation <a class="eqn" href="#eqn2">(2)</a> must be returned.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>The residual defined in equation <a class="eqn" href="#eqn1">(1)</a> must be returned.</dd></dl>
</div>
<div class="paramtext"><i>On exit</i>: should be unchanged unless one of the following actions is required of the integrator, in which case <a class="arg" href="../D02/d02ngf.xml#RESID_IRES">IRES</a> should be set accordingly. 
<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>Indicates to the integrator that control should be passed back immediately to the calling (sub)program with the error indicator set to <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq11"><m:mn mathcolor="#003399" mathvariant="bold">11</m:mn></m:maction></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>Indicates to the integrator that an error condition has occurred in the solution vector, its time derivative or in the value of <m:math><m:mi>t</m:mi></m:math>. The integrator will use a smaller time step to try to avoid this condition. If this is not possible, the integrator returns to the calling (sub)program with the error indicator set to <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq7"><m:mn mathcolor="#003399" mathvariant="bold">7</m:mn></m:maction></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>Indicates to the integrator to stop its current operation and to enter <a class="arg" href="#MONITR">MONITR</a> immediately with parameter <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:math>.</dd></dl>
</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#RESID">RESID</a> must be declared as EXTERNAL in the (sub)program from which D02NGF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
</dd><dt class="paramhead"><a name="YSAV" id="YSAV"/>13: &#8194; YSAV(<a class="arg" href="#LDYSAV">LDYSAV</a>,<a class="arg" href="#SDYSAV">SDYSAV</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Communication Array</span></dt><dt class="multi-paramhead"><a name="SDYSAV" id="SDYSAV"/>14: &#8194; SDYSAV &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the second dimension of the array <a class="arg" href="#YSAV">YSAV</a> as declared in the (sub)program from which D02NGF is called. An appropriate value for <a class="arg" href="#SDYSAV">SDYSAV</a> is described in the specifications of the integrator setup routines <a class="rout" href="../D02/d02mvf.xml">D02MVF</a>, <a class="rout" href="../D02/d02nvf.xml">D02NVF</a> and <a class="rout" href="../D02/d02nwf.xml">D02NWF</a>. This value must be the same as that supplied to the integrator setup routine.</div></dd><dt class="paramhead"><a name="JAC" id="JAC"/>15: &#8194; JAC &#8211; SUBROUTINE, supplied by the NAG Library or the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#JAC">JAC</a> must evaluate the Jacobian of the system. If this option is not required, the actual argument for <a class="arg" href="#JAC">JAC</a> must be the dummy routine D02NGZ.  (D02NGZ is included in the NAG Library.) You must indicate to the integrator whether this option is to be used by setting the parameter <a class="arg" href="../D02/d02nsf.xml#JCEVAL">JCEVAL</a> appropriately in a call to the full linear algebra setup routine <a class="rout" href="../D02/d02nsf.xml">D02NSF</a>.</div>
<div class="paramtext">First we must define the system of nonlinear equations which is solved internally by the integrator. The time derivative, <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>, generated internally, has the form 

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup>
 <m:mo>=</m:mo>
 <m:mfenced separators=""><m:mi>y</m:mi><m:mo>-</m:mo><m:mi>z</m:mi></m:mfenced>
 <m:mo>/</m:mo>
 <m:mfenced separators=""><m:mi>h</m:mi><m:mi>d</m:mi></m:mfenced>
 <m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>
 where <m:math><m:mi>h</m:mi></m:math>&#160;is the current step size and <m:math><m:mi>d</m:mi></m:math>&#160;is a parameter that depends on the integration method in use. The vector <m:math><m:mi>y</m:mi></m:math>&#160;is the current solution and the vector <m:math><m:mi>z</m:mi></m:math>&#160;depends on information from previous time steps. This means that <m:math>
 <m:mfrac>
  <m:mi>d</m:mi>
  <m:mrow><m:mi>d</m:mi><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mrow>
 </m:mfrac>
 <m:mfenced separators=""><m:mtext>&#8203; &#8203;</m:mtext></m:mfenced>
 <m:mo>=</m:mo>
 <m:mfenced separators=""><m:mi>h</m:mi><m:mi>d</m:mi></m:mfenced>
 <m:mfrac>
  <m:mi>d</m:mi>
  <m:mrow><m:mi>d</m:mi><m:mi>y</m:mi></m:mrow>
 </m:mfrac>
 <m:mfenced separators=""><m:mtext>&#8203; &#8203;</m:mtext></m:mfenced>
</m:math>. The system of nonlinear equations that is solved has the form 

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>A</m:mi>
 <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 <m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup>
 <m:mo>-</m:mo>
 <m:mi>g</m:mi>
 <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
</m:math></td><td class="formula2"/></tr></table></div>
 but it is solved in the form 

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>r</m:mi>
 <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
 <m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>
 where <m:math><m:mi>r</m:mi></m:math>&#160;is the function defined by 

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>r</m:mi>
 <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:mfenced separators=""><m:mi>h</m:mi><m:mi>d</m:mi></m:mfenced>
 <m:mfenced separators="">
  <m:mrow>
   <m:mi>A</m:mi>
   <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
   <m:mfenced separators=""><m:mi>y</m:mi><m:mo>-</m:mo><m:mi>z</m:mi></m:mfenced>
   <m:mo>/</m:mo>
   <m:mfenced separators=""><m:mi>h</m:mi><m:mi>d</m:mi></m:mfenced>
   <m:mo>-</m:mo>
   <m:mi>g</m:mi>
   <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
  </m:mrow>
 </m:mfenced>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>
 It is the Jacobian matrix <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>r</m:mi></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>y</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;that you must supply in <a class="arg" href="#JAC">JAC</a> as follows: 

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>y</m:mi><m:mi>j</m:mi></m:msub></m:mrow>
 </m:mfrac>
 <m:mo>=</m:mo>
 <m:msub><m:mi>a</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msub>
 <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 <m:mo>+</m:mo>
 <m:mfenced separators=""><m:mi>h</m:mi><m:mi>d</m:mi></m:mfenced>
 <m:mfrac other="display">
  <m:mo>&#8706;</m:mo>
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>y</m:mi><m:mi>j</m:mi></m:msub></m:mrow>
 </m:mfrac>
 <m:mfenced separators="">
  <m:munderover>
   <m:mo>&#8721;</m:mo>
   <m:mrow><m:mi>k</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
   <m:maction actiontype="link" dsi:type="simple" dsi:href="#JAC_NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction>
  </m:munderover>
  <m:msub><m:mi>a</m:mi><m:mrow><m:mi>i</m:mi><m:mi>k</m:mi></m:mrow></m:msub>
  <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
  <m:msubsup><m:mi>y</m:mi><m:mi>k</m:mi><m:mo>&#8242;</m:mo></m:msubsup>
  <m:mo>-</m:mo>
  <m:msub><m:mi>g</m:mi><m:mi>i</m:mi></m:msub>
  <m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 </m:mfenced>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#JAC">JAC</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;JAC&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02ngf.xml#JAC_NEQ">NEQ</a>, <a class="arg" href="../D02/d02ngf.xml#JAC_T">T</a>, <a class="arg" href="../D02/d02ngf.xml#JAC_Y">Y</a>, <a class="arg" href="../D02/d02ngf.xml#JAC_YDOT">YDOT</a>, <a class="arg" href="../D02/d02ngf.xml#JAC_H">H</a>, <a class="arg" href="../D02/d02ngf.xml#JAC_D">D</a>, <a class="arg" href="../D02/d02ngf.xml#JAC_P">P</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NEQ</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">T, Y(NEQ), YDOT(NEQ), H, D, P(NEQ,NEQ)</td></tr></table>
<dl><dt class="paramhead"><a name="JAC_NEQ" id="JAC_NEQ"/>1: &#160;&#160;&#8194; NEQ &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 

the number of equations being solved.</div></dd><dt class="paramhead"><a name="JAC_T" id="JAC_T"/>2: &#160;&#160;&#8194; T &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mi>t</m:mi></m:math>, the current value of the independent variable.</div></dd><dt class="paramhead"><a name="JAC_Y" id="JAC_Y"/>3: &#160;&#160;&#8194; Y(<a class="arg" href="../D02/d02ngf.xml#JAC_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, the current solution component, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#JAC_NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>.</div></dd><dt class="paramhead"><a name="JAC_YDOT" id="JAC_YDOT"/>4: &#160;&#160;&#8194; YDOT(<a class="arg" href="../D02/d02ngf.xml#JAC_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the derivative of the solution at the current point <m:math><m:mi>t</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="JAC_H" id="JAC_H"/>5: &#160;&#160;&#8194; H &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the current step size.</div></dd><dt class="paramhead"><a name="JAC_D" id="JAC_D"/>6: &#160;&#160;&#8194; D &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the parameter <m:math><m:mi>d</m:mi></m:math>&#160;which depends on the integration method.</div></dd><dt class="paramhead"><a name="JAC_P" id="JAC_P"/>7: &#160;&#160;&#8194; P(<a class="arg" href="../D02/d02ngf.xml#JAC_NEQ">NEQ</a>,<a class="arg" href="../D02/d02ngf.xml#JAC_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: is set to zero.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#JAC_P"><m:mi mathcolor="#EE0000" mathvariant="bold">P</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;must contain <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>y</m:mi><m:mi>j</m:mi></m:msub></m:mrow>
 </m:mfrac>
</m:math>, for <m:math><m:mi>i</m:mi><m:mo>,</m:mo><m:mi>j</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#JAC_NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:math>.
<div class="paramtext">Only nonzero elements of this array need be set, since it is preset to zero before the call to <a class="arg" href="#JAC">JAC</a>.</div>
</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#JAC">JAC</a> must be declared as EXTERNAL in the (sub)program from which D02NGF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
</dd><dt class="paramhead"><a name="WKJAC" id="WKJAC"/>16: &#8194; WKJAC(<a class="arg" href="#NWKJAC">NWKJAC</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Communication Array</span></dt><dt class="multi-paramhead"><a name="NWKJAC" id="NWKJAC"/>17: &#8194; NWKJAC &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the dimension of the array <a class="arg" href="#WKJAC">WKJAC</a> as declared in the (sub)program from which D02NGF is called. This value must be the same as that supplied to the linear algebra setup routine <a class="rout" href="../D02/d02nsf.xml">D02NSF</a>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NWKJAC"><m:mi mathcolor="#EE0000" mathvariant="bold">NWKJAC</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDYSAV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDYSAV</m:mi></m:maction><m:mo>&#215;</m:mo><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDYSAV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDYSAV</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced></m:math>.
</div></dd><dt class="paramhead"><a name="MONITR" id="MONITR"/>18: &#8194; MONITR &#8211; SUBROUTINE, supplied by the NAG Library or the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#MONITR">MONITR</a> performs tasks requested by you. If this option is not required, then the actual argument for <a class="arg" href="#MONITR">MONITR</a> must be the dummy routine D02NBY. (D02NBY is included in the NAG Library.)</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#MONITR">MONITR</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;MONITR&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02ngf.xml#MONITR_NEQ">NEQ</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_LDYSAV">LDYSAV</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_T">T</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_HLAST">HLAST</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_HNEXT">HNEXT</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_Y">Y</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_YDOT">YDOT</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_YSAV">YSAV</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_R">R</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_ACOR">ACOR</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_IMON">IMON</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_INLN">INLN</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_HMIN">HMIN</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_HMAX">HMAX</a>, <a class="arg" href="../D02/d02ngf.xml#MONITR_NQU">NQU</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NEQ, LDYSAV, IMON, INLN, NQU</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">T, HLAST, HNEXT, Y(NEQ), YDOT(NEQ), YSAV(LDYSAV,<m:math><m:mi mathvariant="italic">sdysav</m:mi></m:math>), R(NEQ), ACOR(NEQ,2), HMIN, HMAX</td></tr></table><div class="paramtext">where <m:math><m:mi mathvariant="italic">sdysav</m:mi></m:math>&#160;is the numerical value of <a class="arg" href="#SDYSAV">SDYSAV</a> in the call of D02NGF.</div>
<dl><dt class="paramhead"><a name="MONITR_NEQ" id="MONITR_NEQ"/>1: &#160;&#160;&#8194; NEQ &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 

the number of equations being solved.</div></dd><dt class="paramhead"><a name="MONITR_LDYSAV" id="MONITR_LDYSAV"/>2: &#160;&#160;&#8194; LDYSAV &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: an upper bound on the number of equations to be solved.</div></dd><dt class="paramhead"><a name="MONITR_T" id="MONITR_T"/>3: &#160;&#160;&#8194; T &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the current value of the independent variable.</div></dd><dt class="paramhead"><a name="MONITR_HLAST" id="MONITR_HLAST"/>4: &#160;&#160;&#8194; HLAST &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the last step size successfully used by the integrator.</div></dd><dt class="paramhead"><a name="MONITR_HNEXT" id="MONITR_HNEXT"/>5: &#160;&#160;&#8194; HNEXT &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the step size that the integrator proposes to take on the next step.</div><div class="paramtext"><i>On exit</i>: the next step size to be used. If this is different from the input value, then <a class="arg" href="../D02/d02ngf.xml#MONITR_IMON">IMON</a> must be set to <m:math><m:mn>4</m:mn></m:math>.</div></dd><dt class="paramhead"><a name="MONITR_Y" id="MONITR_Y"/>6: &#160;&#160;&#8194; Y(<a class="arg" href="../D02/d02ngf.xml#MONITR_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mi>y</m:mi></m:math>, the values of the dependent variables evaluated at <m:math><m:mi>t</m:mi></m:math>.</div><div class="paramtext"><i>On exit</i>: these values must not be changed unless <a class="arg" href="../D02/d02ngf.xml#MONITR_IMON">IMON</a> is set to <m:math><m:mn>2</m:mn></m:math>.</div></dd><dt class="paramhead"><a name="MONITR_YDOT" id="MONITR_YDOT"/>7: &#160;&#160;&#8194; YDOT(<a class="arg" href="../D02/d02ngf.xml#MONITR_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the time derivatives <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;of the vector <m:math><m:mi>y</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="MONITR_YSAV" id="MONITR_YSAV"/>8: &#160;&#160;&#8194; YSAV(<a class="arg" href="../D02/d02ngf.xml#MONITR_LDYSAV">LDYSAV</a>,<m:math><m:mi mathvariant="italic">sdysav</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: workspace to enable you to carry out interpolation using either of the routines <a class="rout" href="../D02/d02xjf.xml">D02XJF</a> or <a class="rout" href="../D02/d02xkf.xml">D02XKF</a>.</div></dd><dt class="paramhead"><a name="MONITR_R" id="MONITR_R"/>9: &#160;&#160;&#8194; R(<a class="arg" href="../D02/d02ngf.xml#MONITR_NEQ">NEQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_INLN"><m:mi mathcolor="#EE0000" mathvariant="bold">INLN</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>, then the first <a class="arg" href="../D02/d02ngf.xml#MONITR_NEQ">NEQ</a> elements contain the residual vector <m:math><m:mi>A</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>-</m:mo><m:mi>g</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>.</div></dd><dt class="paramhead"><a name="MONITR_ACOR" id="MONITR_ACOR"/>10: &#8194; ACOR(<a class="arg" href="../D02/d02ngf.xml#MONITR_NEQ">NEQ</a>,<m:math><m:mn>2</m:mn></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>, <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_ACOR"><m:mi mathcolor="#EE0000" mathvariant="bold">ACOR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;contains the weight used for the <m:math><m:mi>i</m:mi></m:math>th equation when the norm is evaluated, and <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_ACOR"><m:mi mathcolor="#EE0000" mathvariant="bold">ACOR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>2</m:mn></m:mfenced></m:mrow></m:math>&#160;contains the estimated local error for the <m:math><m:mi>i</m:mi></m:math>th equation. The scaled local error at the end of a timestep may be obtained by calling the <span class="bitalic">double precision</span> function <a class="rout" href="../D02/d02zaf.xml">D02ZAF</a> as follows:
<pre class="verbatim">
      IFAIL = 1
      ERRLOC = D02ZAF(NEQ, ACOR(1,2), ACOR(1,1), IFAIL)
C     CHECK IFAIL BEFORE PROCEEDING
</pre></div></dd><dt class="paramhead"><a name="MONITR_IMON" id="MONITR_IMON"/>11: &#8194; IMON &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: a flag indicating under what circumstances <a class="arg" href="#MONITR">MONITR</a> was called: 
<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:math></dt>
<dd>Entry from the integrator after <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math>&#160;(set in <a class="arg" href="#RESID">RESID</a>) caused an early termination (this facility could be used to locate discontinuities).</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math></dt>
<dd>The current step failed repeatedly.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>Entry after a call to the internal nonlinear equation solver (see <a class="arg" href="../D02/d02ngf.xml#MONITR_INLN">INLN</a>).</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>The current step was successful.</dd></dl>
</div>
<div class="paramtext"><i>On exit</i>: may be reset to determine subsequent action in D02NGF. 

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:math></dt>
<dd>Integration is to be halted. A return will be made from the integrator to the calling (sub)program with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq12"><m:mn mathcolor="#003399" mathvariant="bold">12</m:mn></m:maction></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math></dt>
<dd>Allow the integrator to continue with its own internal strategy. The integrator will try up to three restarts unless <a class="arg" href="../D02/d02ngf.xml#MONITR_IMON">IMON</a> is set <m:math><m:mtext/><m:mo>&#8800;</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>&#160;on exit.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>Return to the internal nonlinear equation solver, where the action taken is determined by the value of <a class="arg" href="../D02/d02ngf.xml#MONITR_INLN">INLN</a> (see <a class="arg" href="../D02/d02ngf.xml#MONITR_INLN">INLN</a>).</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>Normal exit to the integrator to continue integration.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>Restart the integration at the current time point. The integrator will restart from order <m:math><m:mn>1</m:mn></m:math>&#160;when this option is used. The solution <a class="arg" href="../D02/d02ngf.xml#MONITR_Y">Y</a>, provided by <a class="arg" href="#MONITR">MONITR</a>, will be used for the initial conditions.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>Try to continue with the same step size and order as was to be used before the call to <a class="arg" href="#MONITR">MONITR</a>. <a class="arg" href="../D02/d02ngf.xml#MONITR_HMIN">HMIN</a> and <a class="arg" href="../D02/d02ngf.xml#MONITR_HMAX">HMAX</a> may be altered if desired.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>Continue the integration but using a new value of <a class="arg" href="../D02/d02ngf.xml#MONITR_HNEXT">HNEXT</a> and possibly new values of <a class="arg" href="../D02/d02ngf.xml#MONITR_HMIN">HMIN</a> and <a class="arg" href="../D02/d02ngf.xml#MONITR_HMAX">HMAX</a>.</dd></dl>
</div></dd><dt class="paramhead"><a name="MONITR_INLN" id="MONITR_INLN"/>12: &#8194; INLN &#8211; INTEGER<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the action to be taken by the internal nonlinear equation solver when <a class="arg" href="#MONITR">MONITR</a> is exited with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>. By setting <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_INLN"><m:mi mathcolor="#EE0000" mathvariant="bold">INLN</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;and returning to the integrator, the residual vector is evaluated and placed in the array <a class="arg" href="../D02/d02ngf.xml#MONITR_R">R</a>, and then <a class="arg" href="#MONITR">MONITR</a> is called again. At present this is the only option available: <a class="arg" href="../D02/d02ngf.xml#MONITR_INLN">INLN</a> must not be set to any other value.</div></dd><dt class="paramhead"><a name="MONITR_HMIN" id="MONITR_HMIN"/>13: &#8194; HMIN &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the minimum step size to be taken on the next step.</div><div class="paramtext"><i>On exit</i>: the minimum step size to be used. If this is different from the input value, then <a class="arg" href="../D02/d02ngf.xml#MONITR_IMON">IMON</a> must be set to <m:math><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>.</div></dd><dt class="paramhead"><a name="MONITR_HMAX" id="MONITR_HMAX"/>14: &#8194; HMAX &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the maximum step size to be taken on the next step.</div><div class="paramtext"><i>On exit</i>: the maximum step size to be used. If this is different from the input value, then <a class="arg" href="../D02/d02ngf.xml#MONITR_IMON">IMON</a> must be set to <m:math><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>. If <a class="arg" href="../D02/d02ngf.xml#MONITR_HMAX">HMAX</a> is set to zero, no limit is assumed.</div></dd><dt class="paramhead"><a name="MONITR_NQU" id="MONITR_NQU"/>15: &#8194; NQU &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the order of the integrator used on the last step. This is supplied to enable you to carry out interpolation using either of the routines <a class="rout" href="../D02/d02xjf.xml">D02XJF</a> or <a class="rout" href="../D02/d02xkf.xml">D02XKF</a>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#MONITR">MONITR</a> must be declared as EXTERNAL in the (sub)program from which D02NGF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
</dd><dt class="paramhead"><a name="LDERIV" id="LDERIV"/>19: &#8194; LDERIV(<m:math><m:mn>2</m:mn></m:math>) &#8211; LOGICAL array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 
<m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;must be set to .TRUE. if you have supplied both an initial <m:math><m:mi>y</m:mi></m:math>&#160;and an initial <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>. <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;must be set to .FALSE. if only the initial <m:math><m:mi>y</m:mi></m:math>&#160;has been supplied.
<div class="paramtext"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow></m:math>&#160;must be set to .TRUE. if the integrator is to use a modified Newton method to evaluate the initial <m:math><m:mi>y</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>. Note that <m:math><m:mi>y</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>, if supplied, are used as initial estimates. This method involves taking a small step at the start of the integration, and if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math>&#160;on entry, <a class="arg" href="#T">T</a> and <a class="arg" href="#TOUT">TOUT</a> will be set to the result of taking this small step. <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow></m:math>&#160;must be set to .FALSE. if the integrator is to use functional iteration to evaluate the initial <m:math><m:mi>y</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>, and if this fails a modified Newton method will then be attempted. <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;is recommended if there are implicit equations or the initial <m:math><m:mi>y</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;are zero.</div></div>
<div class="paramtext"><i>On exit</i>: 
<m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;is normally unchanged. However if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math>&#160;and internal initialization was successful then <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>.
<div class="paramtext"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>, if implicit equations were detected. Otherwise <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>.</div></div></dd><dt class="paramhead"><a name="ITASK" id="ITASK"/>20: &#8194; ITASK &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the task to be performed by the integrator. 

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>Normal computation of output values of <m:math><m:mi>y</m:mi><m:mfenced separators=""><m:mi>t</m:mi></m:mfenced></m:math>&#160;at <m:math><m:mi>t</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOUT"><m:mi mathcolor="#EE0000" mathvariant="bold">TOUT</m:mi></m:maction></m:math>&#160;(by overshooting and interpolating).</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>Take one step only and return.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>Stop at the first internal integration point at or beyond <m:math><m:mi>t</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOUT"><m:mi mathcolor="#EE0000" mathvariant="bold">TOUT</m:mi></m:maction></m:math>&#160;and return.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>Normal computation of output values of <m:math><m:mi>y</m:mi><m:mfenced separators=""><m:mi>t</m:mi></m:mfenced></m:math>&#160;at <m:math><m:mi>t</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOUT"><m:mi mathcolor="#EE0000" mathvariant="bold">TOUT</m:mi></m:maction></m:math>&#160;but without overshooting <m:math><m:mi>t</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02nvf.xml#TCRIT"><m:mi mathcolor="#EE0000" mathvariant="bold">TCRIT</m:mi></m:maction></m:math>. <a class="arg" href="../D02/d02nvf.xml#TCRIT">TCRIT</a> must be specified as an option in one of the integrator setup routines prior to the first call to the integrator, or specified in the optional input routine prior to a continuation call. <a class="arg" href="../D02/d02nvf.xml#TCRIT">TCRIT</a> may be equal to or beyond <a class="arg" href="#TOUT">TOUT</a>, but not before it, in the direction of integration.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>5</m:mn></m:math></dt>
<dd>Take one step only and return, without passing <a class="arg" href="../D02/d02nvf.xml#TCRIT">TCRIT</a>. <a class="arg" href="../D02/d02nvf.xml#TCRIT">TCRIT</a> must be specified as under <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math></dt>
<dd>The integrator will solve for the initial values of <m:math><m:mi>y</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;only and then return to the calling (sub)program without doing the integration. This option can be used to check the initial values of <m:math><m:mi>y</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>. Functional iteration or a &#8216;small&#8217; backward Euler method used in conjunction with a damped Newton iteration is used to calculate these values (see <a class="arg" href="#LDERIV">LDERIV</a>). Note that if a backward Euler step is used then the value of <m:math><m:mi>t</m:mi></m:math>&#160;will have been advanced a short distance from the initial point.</dd></dl>
<div class="paramtext"><b>Note:</b>&#160; if D02NGF is recalled with a different value of <a class="arg" href="#ITASK">ITASK</a> (and <a class="arg" href="#TOUT">TOUT</a> altered), then the initialization procedure is repeated, possibly leading to different initial conditions.</div>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>6</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="ITRACE" id="ITRACE"/>21: &#8194; ITRACE &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the level of output that is printed by the integrator. <a class="arg" href="#ITRACE">ITRACE</a> may take the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>, <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mn>1</m:mn></m:math>, <m:math><m:mn>2</m:mn></m:math>&#160;or <m:math><m:mn>3</m:mn></m:math>. 

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRACE"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRACE</m:mi></m:maction><m:mo>&lt;</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math></dt>
<dd><m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>&#160;is assumed and similarly if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRACE"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRACE</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>3</m:mn></m:math>, then <m:math><m:mn>3</m:mn></m:math>&#160;is assumed.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRACE"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRACE</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math></dt>
<dd>No output is generated.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRACE"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRACE</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>Only warning messages are printed on the current error message unit (see <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRACE"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRACE</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>Warning messages are printed as above, and on the current advisory message unit (see <a class="rout" href="../X04/x04abf.xml">X04ABF</a>) output is generated which details Jacobian entries, the nonlinear iteration and the time integration. The advisory messages are given in greater detail the larger the value of <a class="arg" href="#ITRACE">ITRACE</a>.</dd></dl>
</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>22: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>. If you are unfamiliar with this parameter you should refer to <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction for details.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see <a class="sec" href="#errors">Section 6</a>).
<div class="paramtext">For environments where it might be inappropriate to halt program execution when an error is detected, the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is recommended.  If the output of error messages is undesirable, then the value <m:math><m:mn>1</m:mn></m:math>&#160;is recommended.  Otherwise, because for this routine the values of the output parameters may be useful even if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;on exit, the recommended value is <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>.  <b>When the value <m:math><m:mrow><m:mo>-</m:mo><m:mn mathvariant="bold">1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is used it is essential to test the value of <a class="arg" href="#IFAIL">IFAIL</a> on exit.</b></div>
</div></dd></dl><h2 class="standard"><a class="sec" name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">-1</m:mn></m:maction></m:math>, explanatory error messages are output on the current error message unit (as defined by <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div><div class="paramtext">Errors or warnings detected by the routine:</div>
<dl class="ifail">
<dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>
<div class="paramtext">An illegal input was detected on entry, or after an internal call to <a class="arg" href="#MONITR">MONITR</a>. If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRACE"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRACE</m:mi></m:maction><m:mo>&gt;</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>, then the form of the error will be detailed on the current error message unit (see <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq2" id="IFeq2"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>
<div class="paramtext">The maximum number of steps specified has been taken (see the description of optional inputs in the integrator setup routines and the optional input continuation routine, <a class="rout" href="../D02/d02nzf.xml">D02NZF</a>).</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq3" id="IFeq3"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>
<div class="paramtext">With the given values of <a class="arg" href="#RTOL">RTOL</a> and <a class="arg" href="#ATOL">ATOL</a> no further progress can be made across the integration range from the current point <a class="arg" href="#T">T</a>. The components <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction></m:mfenced></m:mrow></m:math>&#160;contain the computed values of the solution at the current point <a class="arg" href="#T">T</a>.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq4" id="IFeq4"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>
<div class="paramtext">There were repeated error test failures on an attempted step, before completing the requested task, but the integration was successful as far as <a class="arg" href="#T">T</a>. The problem may have a singularity, or the local error requirements may be inappropriate.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq5" id="IFeq5"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>5</m:mn></m:math></dt>
<dd>
<div class="paramtext">There were repeated convergence test failures on an attempted step, before completing the requested task, but the integration was successful as far as <a class="arg" href="#T">T</a>. This may be caused by an inaccurate Jacobian matrix or one which is incorrectly computed.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq6" id="IFeq6"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math></dt>
<dd>
<div class="paramtext">Some error weight <m:math><m:msub><m:mi>w</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;became zero during the integration (see the description of <a class="arg" href="#ITOL">ITOL</a>). Pure relative error control (<m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#ATOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ATOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>) was requested on a variable (the <m:math><m:mi>i</m:mi></m:math>th) which has now vanished. The integration was successful as far as <a class="arg" href="#T">T</a>.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq7" id="IFeq7"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>7</m:mn></m:math></dt>
<dd>
<div class="paramtext"><a class="arg" href="#RESID">RESID</a> set its error flag (<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>) continually despite repeated attempts by the integrator to avoid this.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq8" id="IFeq8"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>8</m:mn></m:math></dt>
<dd>
<div class="paramtext"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDERIV"><m:mi mathcolor="#EE0000" mathvariant="bold">LDERIV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>&#160;on entry but the internal initialization routine was unable to initialize <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;(more detailed information may be directed to the current error message unit, see <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq9" id="IFeq9"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>9</m:mn></m:math></dt>
<dd>
<div class="paramtext">A singular Jacobian <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>r</m:mi></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>y</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;has been encountered. You should check the problem formulation and Jacobian calculation.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq10" id="IFeq10"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>10</m:mn></m:math></dt>
<dd>
<div class="paramtext">An error occurred during Jacobian formulation or back-substitution (a more detailed error description may be directed to the current error message unit, see <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq11" id="IFeq11"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>11</m:mn></m:math></dt>
<dd>
<div class="paramtext"><a class="arg" href="#RESID">RESID</a> signalled the integrator to halt the integration and return (<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESID_IRES"><m:mi mathcolor="#EE0000" mathvariant="bold">IRES</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>). Integration was successful as far as <a class="arg" href="#T">T</a>.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq12" id="IFeq12"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>12</m:mn></m:math></dt>
<dd>
<div class="paramtext"><a class="arg" href="#MONITR">MONITR</a> set <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MONITR_IMON"><m:mi mathcolor="#EE0000" mathvariant="bold">IMON</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:math>&#160;and so forced a return but the integration was successful as far as <a class="arg" href="#T">T</a>.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq13" id="IFeq13"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>13</m:mn></m:math></dt>
<dd>
<div class="paramtext">The requested task has been completed, but it is estimated that a small change in <a class="arg" href="#RTOL">RTOL</a> and <a class="arg" href="#ATOL">ATOL</a> is unlikely to produce any change in the computed solution. (Only applies when you are not operating in one step mode, that is when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mn>2</m:mn></m:math>&#160;or <m:math><m:mn>5</m:mn></m:math>.)</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq14" id="IFeq14"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>14</m:mn></m:math></dt>
<dd>
<div class="paramtext">The values of <a class="arg" href="#RTOL">RTOL</a> and <a class="arg" href="#ATOL">ATOL</a> are so small that D02NGF is unable to start the integration.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq15" id="IFeq15"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>15</m:mn></m:math></dt>
<dd>
<div class="paramtext">The linear algebra setup routine <a class="rout" href="../D02/d02nsf.xml">D02NSF</a> was not called before the call to D02NGF.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The accuracy of the numerical solution may be controlled by a careful choice of the parameters <a class="arg" href="#RTOL">RTOL</a> and <a class="arg" href="#ATOL">ATOL</a>, and to a much lesser extent by the choice of norm.  You are advised to use scalar error control unless the components of the solution are expected to be poorly scaled.  For the type of decaying solution typical of many stiff problems, relative error control with a small absolute error threshold will be most appropriate (that is, you are advised to choose <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ITOL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>&#160;with <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#ATOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ATOL</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;small but positive).</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The cost of computing a solution depends critically on the size of the differential system and to a lesser extent on the degree of stiffness of the problem.  For D02NGF the cost is proportional to <m:math><m:msup><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction><m:mn>3</m:mn></m:msup></m:math>, though for problems which are only mildly nonlinear the cost may be dominated by factors proportional to <m:math><m:msup><m:maction actiontype="link" dsi:type="simple" dsi:href="#NEQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NEQ</m:mi></m:maction><m:mn>2</m:mn></m:msup></m:math>&#160;except for very large problems.</div><div class="paramtext">In general, you are advised to choose the BDF option (setup routine <a class="rout" href="../D02/d02nvf.xml">D02NVF</a>) but if efficiency is of great importance and especially if it is suspected that <m:math>
 <m:mfrac other="display">
  <m:mo>&#8706;</m:mo>
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>y</m:mi></m:mrow>
 </m:mfrac>
 <m:mfenced separators=""><m:msup><m:mi>A</m:mi><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msup><m:mi>g</m:mi></m:mfenced>
</m:math>&#160;has complex eigenvalues near the imaginary axis for some part of the integration, you should try the BLEND option (setup routine <a class="rout" href="../D02/d02nwf.xml">D02NWF</a>).</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example solves the well-known stiff Robertson problem written in implicit form

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mtable columnalign="left center right center left center left center left">
 <m:mtr>
  <m:mtd><m:msub><m:mi>r</m:mi><m:mn>1</m:mn></m:msub></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>0.04</m:mn></m:mrow><m:mi>a</m:mi></m:mtd>
  <m:mtd><m:mo>+</m:mo></m:mtd>
  <m:mtd><m:mn>1.0</m:mn><m:mi mathvariant="normal">E</m:mi><m:mn>4</m:mn><m:mi>b</m:mi><m:mi>c</m:mi></m:mtd>
  <m:mtd/>
  <m:mtd/>
  <m:mtd><m:mo>-</m:mo></m:mtd>
  <m:mtd><m:msup><m:mi>a</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd><m:msub><m:mi>r</m:mi><m:mn>2</m:mn></m:msub></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mn>0.04</m:mn><m:mi>a</m:mi></m:mtd>
  <m:mtd><m:mo>-</m:mo></m:mtd>
  <m:mtd><m:mn>1.0</m:mn><m:mi mathvariant="normal">E</m:mi><m:mn>4</m:mn><m:mi>b</m:mi><m:mi>c</m:mi></m:mtd>
  <m:mtd><m:mo>-</m:mo></m:mtd>
  <m:mtd><m:mn>3.0</m:mn><m:mi mathvariant="normal">E</m:mi><m:mn>7</m:mn><m:mo>&#8290;</m:mo><m:msup><m:mi>b</m:mi><m:mn>2</m:mn></m:msup></m:mtd>
  <m:mtd><m:mo>-</m:mo></m:mtd>
  <m:mtd><m:msup><m:mi>b</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd><m:msub><m:mi>r</m:mi><m:mn>3</m:mn></m:msub></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd/>
  <m:mtd/>
  <m:mtd/>
  <m:mtd/>
  <m:mtd><m:mn>3.0</m:mn><m:mi mathvariant="normal">E</m:mi><m:mn>7</m:mn><m:mo>&#8290;</m:mo><m:msup><m:mi>b</m:mi><m:mn>2</m:mn></m:msup></m:mtd>
  <m:mtd><m:mo>-</m:mo></m:mtd>
  <m:mtd><m:msup><m:mi>c</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mtd>
 </m:mtr>
</m:mtable>
</m:math></td><td class="formula2"/></tr></table></div></div><div class="paramtext">with initial conditions <m:math><m:mi>a</m:mi><m:mo>=</m:mo><m:mn>1.0</m:mn></m:math>&#160;and <m:math><m:mi>b</m:mi><m:mo>=</m:mo><m:mi>c</m:mi><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>&#160;over the range <m:math><m:mfenced separators="" open="[" close="]"><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>0.1</m:mn></m:mfenced></m:math>&#160;with vector error control (<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITOL"><m:mi mathcolor="#EE0000" mathvariant="bold">ITOL</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math>), the BDF method (setup routine <a class="rout" href="../D02/d02nvf.xml">D02NVF</a>) and functional iteration.  The Jacobian is calculated numerically if the functional iteration encounters difficulty and the integration is in one-step mode  (<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITASK"><m:mi mathcolor="#EE0000" mathvariant="bold">ITASK</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>), with <m:math><m:msup><m:mi mathvariant="normal">C</m:mi><m:mn>0</m:mn></m:msup></m:math>&#160;interpolation to calculate the solution at intervals of <m:math><m:mn>0.02</m:mn></m:math>&#160;using <a class="rout" href="../D02/d02xjf.xml">D02XJF</a> externally.  D02NBY is used for <a class="arg" href="#MONITR">MONITR</a>.</div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<p><a class="verbatimref" href="../../examples/source/d02ngfe.f">Program Text (d02ngfe.f)</a></p><h3 class="standard"><a class="sec" name="examdata" id="examdata"/>9.2&#160;&#160;Program Data</h3>
<div class="paramtext">None.</div><h3 class="standard"><a class="sec" name="examresults" id="examresults"/>9.3&#160;&#160;Program Results</h3>
<p><a class="verbatimref" href="../../examples/baseresults/d02ngfe.r">Program Results (d02ngfe.r)</a></p><div class="figure"><a name="d02ngf-plot" id="d02ngf-plot"/><img src="../figures/d02ngf-plot.png" alt="Example Program Plot for d02ngf-plot"/></div>
<hr/><div><a class="rout" href="../../pdf/D02/d02ngf.pdf">D02NGF (PDF version)</a></div><div><a class="chap" href="d02conts.xml">D02 Chapter Contents</a></div><div><a class="chapint" href="d02intro.xml">D02 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div>
<div><hr/><a class="genint" href="../FRONTMATTER/copyright.xml">&#169; The Numerical Algorithms Group Ltd, Oxford, UK. 2009</a></div></body></html>
