<?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>D02PCF : 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/d02pcf.pdf">D02PCF (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/>D02PCF</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">D02PCF solves an initial value problem for a first-order system of ordinary differential equations using Runge&#8211;Kutta methods.</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;D02PCF&#160;(</td><td class="tdfspec2"><a class="arg" href="#F">F</a>, <a class="arg" href="#TWANT">TWANT</a>, <a class="arg" href="#TGOT">TGOT</a>, <a class="arg" href="#YGOT">YGOT</a>, <a class="arg" href="#YPGOT">YPGOT</a>, <a class="arg" href="#YMAX">YMAX</a>, <a class="arg" href="#WORK">WORK</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">TWANT, TGOT, YGOT(*), YPGOT(*), YMAX(*), WORK(*)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">F</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02PCF and its associated routines (<a class="rout" href="../D02/d02pvf.xml">D02PVF</a>, <a class="rout" href="../D02/d02pyf.xml">D02PYF</a> and <a class="rout" href="../D02/d02pzf.xml">D02PZF</a>) solve an initial value problem for a first-order system of ordinary differential equations.  The routines, based on Runge&#8211;Kutta methods and derived from RKSUITE (see <a class="ref" href="#ref477">Brankin <span class="italic">et al.</span> (1991)</a>), integrate

<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:mi>f</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mtext>&#8195; given &#8195;</m:mtext><m:mi>y</m:mi><m:mfenced separators=""><m:msub><m:mi>t</m:mi><m:mn>0</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>y</m:mi><m:mn>0</m:mn></m:msub>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>y</m:mi></m:math>&#160;is the vector of <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;solution components and <m:math><m:mi>t</m:mi></m:math>&#160;is the independent variable.</div><div class="paramtext">D02PCF is designed for the usual task, namely to compute an approximate solution at a sequence of points.  You must first call <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> to specify the problem and how it is to be solved.  Thereafter you call D02PCF repeatedly with successive values of <a class="arg" href="#TWANT">TWANT</a>, the points at which you require the solution,  in the range from <a class="arg" href="../D02/d02pvf.xml#TSTART">TSTART</a> to <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a> (as specified in <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>).  In this manner D02PCF returns the point at which it has computed a solution <a class="arg" href="#TGOT">TGOT</a> (usually <a class="arg" href="#TWANT">TWANT</a>), the solution there (<a class="arg" href="#YGOT">YGOT</a>) and its derivative (<a class="arg" href="#YPGOT">YPGOT</a>).  If D02PCF encounters some difficulty in taking a step toward <a class="arg" href="#TWANT">TWANT</a>, then it returns the point of difficulty (<a class="arg" href="#TGOT">TGOT</a>) and the solution and derivative computed there (<a class="arg" href="#YGOT">YGOT</a> and <a class="arg" href="#YPGOT">YPGOT</a>, respectively).</div><div class="paramtext">In the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> you can specify either the first step size for D02PCF to attempt or that it compute automatically an appropriate value.  Thereafter D02PCF estimates an appropriate step size for its next step.  This value and other details of the integration can be obtained after any call to D02PCF by a call to <a class="rout" href="../D02/d02pyf.xml">D02PYF</a>.  The local error is controlled at every step as specified in <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  If you wish to assess the true error, you must set <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  This assessment can be obtained after any call to D02PCF by a call to <a class="rout" href="../D02/d02pzf.xml">D02PZF</a>.</div><div class="paramtext">For more complicated tasks, you are referred to routines <a class="rout" href="../D02/d02pdf.xml">D02PDF</a>, <a class="rout" href="../D02/d02pwf.xml">D02PWF</a> and <a class="rout" href="../D02/d02pxf.xml">D02PXF</a>, all of which are used by D02PCF.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref477" id="ref477"/>Brankin R W, Gladwell I and Shampine L F (1991)  RKSUITE: A suite of Runge&#8211;Kutta codes for the initial value problems for ODEs <i>SoftReport 91-S1</i> Southern Methodist University </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="F" id="F"/>1: &#160;&#160;&#8194; F &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#F">F</a> must evaluate the functions <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;(that is the first derivatives <m:math><m:msubsup><m:mi>y</m:mi><m:mi>i</m:mi><m:mo>&#8242;</m:mo></m:msubsup></m:math>) for given values of the arguments <m:math><m:mi>t</m:mi></m:math>, <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#F">F</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;F&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02pcf.xml#F_T">T</a>, <a class="arg" href="../D02/d02pcf.xml#F_Y">Y</a>, <a class="arg" href="../D02/d02pcf.xml#F_YP">YP</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">T, Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), YP(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;is the value of <a class="arg" href="../D02/d02pvf.xml#NEQ">NEQ</a> in the call of D02PCF.</div>
<dl><dt class="paramhead"><a name="F_T" id="F_T"/>1: &#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="F_Y" id="F_Y"/>2: &#160;&#160;&#8194; Y(<m:math><m:mi mathvariant="italic">n</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>: the current values of the dependent variables, <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:mi mathvariant="italic">n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="F_YP" id="F_YP"/>3: &#160;&#160;&#8194; YP(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the values of <m:math><m:msub><m:mi>f</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:mi mathvariant="italic">n</m:mi></m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#F">F</a> must be declared as EXTERNAL in the (sub)program from which D02PCF 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="TWANT" id="TWANT"/>2: &#160;&#160;&#8194; TWANT &#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 next value of the independent variable where a solution is desired.</div><div class="paramtext"><i>Constraint</i>:
  <a class="arg" href="#TWANT">TWANT</a> must be closer to <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a> than the previous value of <a class="arg" href="#TGOT">TGOT</a> (or <a class="arg" href="../D02/d02pvf.xml#TSTART">TSTART</a> on the first call to D02PCF); see <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> for a description of <a class="arg" href="../D02/d02pvf.xml#TSTART">TSTART</a> and <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>. <a class="arg" href="#TWANT">TWANT</a> must not lie beyond <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a> in the direction of integration.</div></dd><dt class="paramhead"><a name="TGOT" id="TGOT"/>3: &#160;&#160;&#8194; TGOT &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: <m:math><m:mi>t</m:mi></m:math>, the value of the independent variable at which a solution has been computed. On successful exit 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="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>, <a class="arg" href="#TGOT">TGOT</a> will equal <a class="arg" href="#TWANT">TWANT</a>. On exit 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>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq2"><m:mn mathcolor="#003399" mathvariant="bold">1</m:mn></m:maction></m:math>, a solution has still been computed at the value of <a class="arg" href="#TGOT">TGOT</a> but in general <a class="arg" href="#TGOT">TGOT</a> will not equal <a class="arg" href="#TWANT">TWANT</a>.</div></dd><dt class="paramhead"><a name="YGOT" id="YGOT"/>4: &#160;&#160;&#8194; YGOT(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#YGOT">YGOT</a>
must be at least
<m:math><m:mi mathvariant="italic">n</m:mi></m:math>.</div>
<div class="paramtext"><i>On entry</i>: on the first call to D02PCF, <a class="arg" href="#YGOT">YGOT</a> need not be set. On all subsequent calls <a class="arg" href="#YGOT">YGOT</a> must remain unchanged.</div>
<div class="paramtext"><i>On exit</i>: an approximation to the true solution at the value of <a class="arg" href="#TGOT">TGOT</a>. At each step of the integration to <a class="arg" href="#TGOT">TGOT</a>, the local error has been controlled as specified in <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>. The local error has still been controlled even when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TGOT"><m:mi mathcolor="#EE0000" mathvariant="bold">TGOT</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TWANT"><m:mi mathcolor="#EE0000" mathvariant="bold">TWANT</m:mi></m:maction></m:math>, that is after a return 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>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq2"><m:mn mathcolor="#003399" mathvariant="bold">1</m:mn></m:maction></m:math>.</div></dd><dt class="paramhead"><a name="YPGOT" id="YPGOT"/>5: &#160;&#160;&#8194; YPGOT(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#YPGOT">YPGOT</a>
must be at least
<m:math><m:mi mathvariant="italic">n</m:mi></m:math>.</div>
<div class="paramtext"><i>On exit</i>: an approximation to the first derivative of the true solution at <a class="arg" href="#TGOT">TGOT</a>.</div></dd><dt class="paramhead"><a name="YMAX" id="YMAX"/>6: &#160;&#160;&#8194; YMAX(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#YMAX">YMAX</a>
must be at least
<m:math><m:mi mathvariant="italic">n</m:mi></m:math>.</div>
<div class="paramtext"><i>On entry</i>: on the first call to D02PCF, <a class="arg" href="#YMAX">YMAX</a> need not be set. On all subsequent calls <a class="arg" href="#YMAX">YMAX</a> must remain unchanged.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#YMAX"><m:mi mathcolor="#EE0000" mathvariant="bold">YMAX</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;contains the largest value of <m:math><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:math>&#160;computed at any step in the integration so far.</div></dd><dt class="paramhead"><a name="WORK" id="WORK"/>7: &#160;&#160;&#8194; WORK(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#WORK">WORK</a>
must be at least
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#LENWRK"><m:mi mathcolor="#EE0000" mathvariant="bold">LENWRK</m:mi></m:maction></m:math>&#160;(see <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>).</div>
<div class="paramtext"><i>On entry</i>: this <b>must</b> be the same array as supplied to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>. It <b>must</b> remain unchanged between calls.</div>
<div class="paramtext"><i>On exit</i>: information about the integration for use on subsequent calls to D02PCF or other associated routines.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>8: &#160;&#160;&#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">On entry, an invalid input value for <a class="arg" href="#TWANT">TWANT</a> was detected or an invalid call to D02PCF was made, for example without a previous call to the setup routine <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  You cannot continue integrating the problem.</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">This return is possible only when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;has been selected in the preceding call of <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  D02PCF is being used inefficiently because the step size has been reduced drastically many times to get answers at many values of <a class="arg" href="#TWANT">TWANT</a>.  If you really need the solution at this many points, you should change to <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>&#160;because it is (much) more efficient in this situation.  To change <a class="arg" href="../D02/d02pvf.xml#METHOD">METHOD</a>, restart the integration from <a class="arg" href="#TGOT">TGOT</a>, <a class="arg" href="#YGOT">YGOT</a> by a call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  If you wish to continue with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>, just call D02PCF again without altering any of the arguments other than <a class="arg" href="#IFAIL">IFAIL</a>.  The monitor of this kind of inefficiency will be reset automatically so that the integration can proceed.</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">A considerable amount of work has been expended in the (primary) integration.  This is measured by counting the number of calls to the supplied routine <a class="arg" href="#F">F</a>.  At least <m:math><m:mn>5000</m:mn></m:math>&#160;calls have been made since the last time this counter was reset.  Calls to <a class="arg" href="#F">F</a> in a secondary integration for global error assessment (when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>) are not counted in this total.  The integration was interrupted, so <a class="arg" href="#TGOT">TGOT</a> is not equal to <a class="arg" href="#TWANT">TWANT</a>.  If you wish to continue on towards <a class="arg" href="#TWANT">TWANT</a>, just call D02PCF again without altering any of the arguments other than <a class="arg" href="#IFAIL">IFAIL</a>.  The counter measuring work will be reset to zero automatically.</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">It appears that this problem is stiff.  The methods implemented in D02PCF can solve such problems, but they are inefficient.  You should change to another code based on methods appropriate for stiff problems.  The integration was interrupted so <a class="arg" href="#TGOT">TGOT</a> is not equal to <a class="arg" href="#TWANT">TWANT</a>.  If you want to continue on towards <a class="arg" href="#TWANT">TWANT</a>, just call D02PCF again without altering any of the arguments other than <a class="arg" href="#IFAIL">IFAIL</a>.  The stiffness monitor will be reset automatically.</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">It does not appear possible to achieve the accuracy specified by <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a> in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> with the precision available on the computer being used and with this value of <a class="arg" href="../D02/d02pvf.xml#METHOD">METHOD</a>.  You cannot continue integrating this problem.  A larger value for <a class="arg" href="../D02/d02pvf.xml#METHOD">METHOD</a>, if possible, will permit greater accuracy with this precision.  To increase <a class="arg" href="../D02/d02pvf.xml#METHOD">METHOD</a> and/or continue with larger values of <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and/or <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a>, restart the integration from <a class="arg" href="#TGOT">TGOT</a>, <a class="arg" href="#YGOT">YGOT</a> by a call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.</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">(This error exit can only occur if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.)  The global error assessment may not be reliable beyond the current integration point <a class="arg" href="#TGOT">TGOT</a>.  This may occur because either too little or too much accuracy has been requested or because <m:math><m:mi>f</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;is not smooth enough for values of <m:math><m:mi>t</m:mi></m:math>&#160;just past <a class="arg" href="#TGOT">TGOT</a> and current values of the solution <m:math><m:mi>y</m:mi></m:math>.  The integration cannot be continued.  This return does not mean that you cannot integrate past <a class="arg" href="#TGOT">TGOT</a>, rather that you cannot do it with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>.  However, it may also indicate problems with the primary integration.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The accuracy of integration is determined by the parameters <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a> in a prior call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> (see the routine document for <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> for further details and advice).  Note that only the local error at each step is controlled by these parameters.  The error estimates obtained are not strict bounds but are usually reliable over one step.  Over a number of steps the overall error may accumulate in various ways, depending on the properties of the differential system.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">If D02PCF returns 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="#IFeq5"><m:mn mathcolor="#003399" mathvariant="bold">5</m:mn></m:maction></m:math>&#160;and the accuracy specified by <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a> is really required then you should consider whether there is a more fundamental difficulty.  For example, the solution may contain a singularity.  In such a region the solution components will usually be large in magnitude.  Successive output values of <a class="arg" href="#YGOT">YGOT</a> and <a class="arg" href="#YMAX">YMAX</a> should be monitored  (or <a class="rout" href="../D02/d02pdf.xml">D02PDF</a> should be used since this takes one integration step at a time)  with the aim of trapping the solution before the singularity.  In any case numerical integration cannot be continued through a singularity, and analytical treatment may be necessary.</div><div class="paramtext">Performance statistics are available after any return from D02PCF by a call to <a class="rout" href="../D02/d02pyf.xml">D02PYF</a>.  If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>,  global error assessment is available after any return from D02PCF (except when <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="#IFeq1"><m:mn mathcolor="#003399" mathvariant="bold">1</m:mn></m:maction></m:math>) by a call to <a class="rout" href="../D02/d02pzf.xml">D02PZF</a>.</div><div class="paramtext">After a failure 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="#IFeq5"><m:mn mathcolor="#003399" mathvariant="bold">5</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq6"><m:mn mathcolor="#003399" mathvariant="bold">6</m:mn></m:maction></m:math>&#160;the diagnostic routines <a class="rout" href="../D02/d02pyf.xml">D02PYF</a> and <a class="rout" href="../D02/d02pzf.xml">D02PZF</a> may be called only once.</div><div class="paramtext">If D02PCF returns 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="#IFeq4"><m:mn mathcolor="#003399" mathvariant="bold">4</m:mn></m:maction></m:math>&#160;then it is advisable to change to another code more suited to the solution of stiff problems.  D02PCF will not return 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="#IFeq4"><m:mn mathcolor="#003399" mathvariant="bold">4</m:mn></m:maction></m:math>&#160;if the problem is actually stiff but it is estimated that integration can be completed using less function evaluations than already computed.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example solves the equation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msup><m:mi>y</m:mi><m:mrow><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo></m:mrow></m:msup><m:mo>=</m:mo><m:mo>-</m:mo><m:mi>y</m:mi><m:mtext>, &#8195;</m:mtext><m:mi>y</m:mi><m:mfenced separators=""><m:mn>0</m:mn></m:mfenced><m:mo>=</m:mo><m:mn>0</m:mn><m:mtext>, &#8195;</m:mtext> <m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mfenced separators=""><m:mn>0</m:mn></m:mfenced><m:mo>=</m:mo><m:mn>1</m:mn>
</m:math></td><td class="formula2"/></tr></table></div>

reposed as

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msubsup><m:mi>y</m:mi><m:mn>1</m:mn><m:mo>&#8242;</m:mo></m:msubsup><m:mo>=</m:mo><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub>
</m:math></td><td class="formula2"/></tr></table></div><div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msubsup><m:mi>y</m:mi><m:mn>2</m:mn><m:mo>&#8242;</m:mo></m:msubsup><m:mo>=</m:mo><m:mo>-</m:mo><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub>
</m:math></td><td class="formula2"/></tr></table></div>

over the range <m:math><m:mfenced separators="" open="[" close="]"><m:mn>0</m:mn><m:mo>,</m:mo><m:mrow><m:mn>2</m:mn><m:mi>&#960;</m:mi></m:mrow></m:mfenced></m:math>&#160;with initial conditions <m:math><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>&#160;and <m:math><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:mn>1.0</m:mn></m:math>.  Relative error control is used with threshold values of <m:math><m:mtext>1.0D&#8722;8</m:mtext></m:math>&#160;for each solution component and compute the solution at intervals of length <m:math><m:mi>&#960;</m:mi><m:mo>/</m:mo><m:mn>4</m:mn></m:math>&#160;across the range.  A low-order Runge&#8211;Kutta method (<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>, see <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>) is also used with tolerances <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>1.0D&#8722;3</m:mtext></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>1.0D&#8722;4</m:mtext></m:math>&#160;in turn so that the solutions can be compared.  The value of <m:math><m:mi>&#960;</m:mi></m:math>&#160;is obtained by using <a class="rout" href="../X01/x01aaf.xml">X01AAF</a>.</div><div class="paramtext">Note that the length of <a class="arg" href="#WORK">WORK</a> is large enough for any valid combination of input arguments to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.</div><div class="paramtext">See also <a class="sec" href="../D02/d02pzf.xml#example">Section 9</a> in D02PZF.</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/d02pcfe.f">Program Text (d02pcfe.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/d02pcfe.r">Program Results (d02pcfe.r)</a></p><div class="figure"><a name="d02pcf-plot" id="d02pcf-plot"/><img src="../figures/d02pcf-plot.png" alt="Example Program Plot for d02pcf-plot"/></div>
<hr/><div><a class="rout" href="../../pdf/D02/d02pcf.pdf">D02PCF (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>
