<!----><?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>Essential Introduction : 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="genint" href="../../pdf/GENINT/essint.pdf">Essential Introduction (PDF version)</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div><hr/><h1 class="libdoc">NAG Library<br/><br/>Essential Introduction</h1><div class="paramtext"><b>Note:</b> <span class="italic">this document is essential reading for any prospective user of the library.</span></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="#summary">1&#160;&#160;<b>Summary for All Users</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('toclibanddoc');"><span class="htmltocplus" id="toclibanddocplus">+</span><span class="htmltocminus" id="toclibanddocminus">&#8722;</span></span>
<a class="htmltoc" href="#libanddoc">2&#160;&#160;<b>The Library and its Documentation</b></a>
<div class="htmltocitem" id="toclibanddoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#libanddoc1">2.1&#160;&#160;<b>Structure of the Library</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#libanddoc2">2.2&#160;&#160;<b>Structure of the Documentation</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#libanddoc5">2.3&#160;&#160;<b>Implementations of the Library</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#libanddoc7">2.4&#160;&#160;<b>Library Identification</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#libanddoc8">2.5&#160;&#160;<b>Fortran Language Standards</b></a>
</div>
</div>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('toclibrary');"><span class="htmltocplus" id="toclibraryplus">+</span><span class="htmltocminus" id="toclibraryminus">&#8722;</span></span>
<a class="htmltoc" href="#library">3&#160;&#160;<b>Using the Library</b></a>
<div class="htmltocitem" id="toclibrary">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#library1">3.1&#160;&#160;<b>General Advice</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#library2">3.2&#160;&#160;<b>Programming Advice</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('toclibrary3');"><span class="htmltocplus" id="toclibrary3plus">+</span><span class="htmltocminus" id="toclibrary3minus">&#8722;</span></span>
<a class="htmltoc" href="#library3">3.3&#160;&#160;<b>Error Handling and the Parameter IFAIL</b></a>
<div class="htmltocitem" id="toclibrary3">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#background1">3.3.1&#160;&#160;<b>Errors, Failure and Warning Conditions</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#background2">3.3.2&#160;&#160;<b>The IFAIL Parameter</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#background3">3.3.3&#160;&#160;<b>Hard Fail Option</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#background4">3.3.4&#160;&#160;<b>Soft Fail Option</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#background5">3.3.5&#160;&#160;<b>Historical Note</b></a>
</div>
</div>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#library4">3.4&#160;&#160;<b>Input/output in the Library</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#library5">3.5&#160;&#160;<b>Auxiliary Routines</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#dynamicmemory">3.6&#160;&#160;<b>Dynamic Memory Allocation</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#licman">3.7&#160;&#160;<b>License Management</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#threadsafety">3.8&#160;&#160;<b>Thread Safety</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#SMPperformance">3.9&#160;&#160;<b>Performance on SMP systems</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#library7">3.10&#160;&#160;<b>Calling the Library from Other Languages</b></a>
</div>
</div>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocdoc');"><span class="htmltocplus" id="tocdocplus">+</span><span class="htmltocminus" id="tocdocminus">&#8722;</span></span>
<a class="htmltoc" href="#doc">4&#160;&#160;<b>Using the Documentation</b></a>
<div class="htmltocitem" id="tocdoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#doc1">4.1&#160;&#160;<b>Using the Manual</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#doc2">4.2&#160;&#160;<b>Structure of Routine Documents</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocdoc3');"><span class="htmltocplus" id="tocdoc3plus">+</span><span class="htmltocminus" id="tocdoc3minus">&#8722;</span></span>
<a class="htmltoc" href="#doc3">4.3&#160;&#160;<b>Specification of Parameters</b></a>
<div class="htmltocitem" id="tocdoc3">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#doc31">4.3.1&#160;&#160;<b>Classification of parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#doc32">4.3.2&#160;&#160;<b>Constraints and suggested values</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#doc33">4.3.3&#160;&#160;<b>Array parameters</b></a>
</div>
</div>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#doc4">4.4&#160;&#160;<b>Implementation-dependent Information</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#doc5">4.5&#160;&#160;<b>Example Programs and Results</b></a>
</div>
</div>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#support">5&#160;&#160;<b>Support from NAG</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#further">6&#160;&#160;<b>Background to NAG</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">7&#160;&#160;<b>References</b></a>
</div>
</div>
</div><h2 class="standard"><a class="sec" name="summary" id="summary"/>1&#160;&#160;Summary for All Users</h2>
<div class="paramtext">All users both familiar or unfamiliar with this Library who are thinking of using a routine from it, are asked to please follow these instructions: 
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline"><a name="itema" id="itema"/>(a)</td>
<td valign="top">read the whole of this <b>Essential Introduction</b>;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="itemb" id="itemb"/>(b)</td>
<td valign="top">select an appropriate chapter or routine by:
  <ul class="listind"><li class="listind">&#8211; searching through the <b><a class="genint" href="../INDEXES/KWIC/kwic.xml#KWIC">Keyword Index</a></b>;</li><li class="listind">&#8211; searching via online search facility;</li><li class="listind">&#8211; consulting the <b><a class="genint" href="../GENINT/libconts.xml#LIBCONTS">Library Contents</a></b> list; or</li><li class="listind">&#8211; searching through the <b><a class="genint" href="../INDEXES/GAMS/gams.xml#GAMS">GAMS Classification Index</a></b>;</li></ul></td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="itemc" id="itemc"/>(c)</td>
<td valign="top">read the relevant <b>Chapter Introduction</b>;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="itemd" id="itemd"/>(d)</td>
<td valign="top">choose a routine, and read the <b>routine document</b>. If the routine does not after all meet your needs, return to step <a class="item" href="#itemb">(b)</a>;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="iteme" id="iteme"/>(e)</td>
<td valign="top">read the <b><a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a></b> for your implementation;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="itemf" id="itemf"/>(f)</td>
<td valign="top">consult local documentation, which should be provided by your local support staff, about access to the Library on your computing system;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="itemg" id="itemg"/>(g)</td>
<td valign="top">obtain an online copy of the example program for the particular routine of interest and experiment with it.</td>
</tr></table>
</div><div class="paramtext">You should now be in a position to include a call to the routine in a program, and to attempt to compile and run it. You may of course need to refer back to the relevant documentation in the case of difficulties, for advice on assessment of results, and so on.</div><div class="paramtext">As you become familiar with the Library, some of steps <a class="item" href="#itema">(a)</a> to <a class="item" href="#itemg">(g)</a> can be omitted, but it is always essential to: 
<ul class="listind"><li class="listind">be familiar with this <b>Essential Introduction</b>;</li><li class="listind">be familiar with the <b>Chapter Introduction</b>;</li><li class="listind">read the <b>routine document</b>;</li><li class="listind">be aware of the <b><a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a></b> for your implementation.</li></ul>
</div><h2 class="standard"><a class="sec" name="libanddoc" id="libanddoc"/>2&#160;&#160;The Library and its Documentation</h2><h3 class="standard"><a class="sec" name="libanddoc1" id="libanddoc1"/>2.1&#160;&#160;Structure of the Library</h3>
<div class="paramtext">The NAG Library is a comprehensive collection of <b>routines</b> for the solution of numerical and statistical problems.</div><div class="paramtext">The NAG Library for SMP &amp; Multicore is the same collection of routines as those available in the NAG Library, many of which have been specially tuned to maximize their performance on Symmetric Multiprocessor (SMP) machines. The document entitled &#8216;<a class="genint" href="../GENINT/smpint.xml#SMPINT">Introduction to the NAG Library for SMP &amp; Multicore</a>&#8217; is <span class="bitalic">essential</span> reading for NAG Library for SMP &amp; Multicore users.</div><div class="paramtext">The Library is divided into <b>chapters</b>, each devoted to a branch of numerical analysis or statistics.  Each chapter has a three-character name and a title, 
e.g.,
<ul class="listind"><li class="listind"><a class="chap" href="../D01/d01conts.xml">Chapter D01 &#8211; Quadrature</a></li></ul>
</div><div class="paramtext">Exceptionally, <a class="chap" href="../H/hconts.xml">Chapters H</a> and <a class="chap" href="../S/sconts.xml">S</a> have one-character names. The chapters and their names are based on the ACM modified SHARE classification index (see <a class="ref" href="#ref226">ACM (1960&#8211;1976)</a>).</div><div class="paramtext">All documented routines in the Library have six-character names, beginning with the characters of the chapter name, 
e.g.,
<ul class="listind"><li class="listind"><a class="rout" href="../D01/d01ajf.xml">D01AJF</a></li></ul>
</div><div class="paramtext">Note that the second and third characters are <b>digits</b>, not letters; e.g., 0 is the digit zero, not the letter O. The last letter of each routine name almost always appears as &#8216;F&#8217; in the documentation. <a class="chap" href="../C05/c05conts.xml">Chapters C05</a>, <a class="chap" href="../D03/d03conts.xml">D03</a> and <a class="chap" href="../E04/e04conts.xml">E04</a> have some routines whose last letter is &#8216;A&#8217; rather than &#8216;F&#8217;.  An &#8216;A&#8217; version is always paired with an &#8216;F&#8217; routine, the &#8216;A&#8217; version being safe to use in a multithreaded environment, but otherwise having identical functionality to the &#8216;F&#8217; version.</div><div class="paramtext"><a class="chap" href="../F06/f06conts.xml">Chapter F06</a> (<a class="chap" href="../F06/f06conts.xml">Linear Algebra Support Routines</a>) contains all the Basic Linear Algebra Subprograms, BLAS, with NAG-style names as well as with the actual BLAS names, e.g., <a class="rout" href="../F06/f06paf.xml">F06PAF (DGEMV)</a>.  The names in brackets are the equivalent double precision BLAS names. <a class="chap" href="../F07/f07conts.xml">Chapter F07</a> (<a class="chap" href="../F07/f07conts.xml">Linear Equations (LAPACK)</a>) and <a class="chap" href="../F08/f08conts.xml">Chapter F08</a> (<a class="chap" href="../F08/f08conts.xml">Least-squares and Eigenvalue Problems (LAPACK)</a>) contain routines derived from the LAPACK project.  Like the BLAS, these routines have NAG-style names as well as LAPACK names, e.g., <a class="rout" href="../F07/f07adf.xml">F07ADF (DGETRF)</a>.  Details regarding these alternate names can be found in the relevant Chapter Introductions.</div><div class="paramtext">In order to take full advantage of machine-specific versions of BLAS and LAPACK routines provided by some computer hardware vendors, you are encouraged to use the BLAS and LAPACK names (e.g., <a class="rout" href="../F06/f06paf.xml">DGEMV</a> and <a class="rout" href="../F07/f07adf.xml">DGETRF</a>) rather than the corresponding NAG-style names (e.g., <a class="rout" href="../F06/f06paf.xml">F06PAF</a> and <a class="rout" href="../F07/f07adf.xml">F07ADF</a>) wherever possible in your programs.</div><h3 class="standard"><a class="sec" name="libanddoc2" id="libanddoc2"/>2.2&#160;&#160;Structure of the Documentation</h3>
<div class="paramtext">The NAG Library Manual is the principal documentation for both the NAG Library and the NAG Library for SMP &amp; Multicore.

It has the same chapter structure as the Library: each chapter of routines in the Library has a corresponding chapter (of the same name) in the Manual.  The chapters occur in alphanumeric order.  General introductory documents appear at the beginning of the Manual.</div><div class="paramtext">Each chapter consists of the following documents:
<ul class="listind"><li class="listind"><b>Chapter Contents</b>, e.g., <a class="chap" href="../D01/d01conts.xml">Chapter D01</a>;</li><li class="listind"><b>Chapter Introduction</b>, e.g., the <a class="chapint" href="../D01/d01intro.xml">D01 Chapter Introduction</a>;</li><li class="listind"><b>Routine Documents</b>, one for each documented routine in the chapter.</li></ul>
</div><div class="paramtext">A routine document has the same name as the routine which it describes.  Within each chapter, routine documents occur in alphanumeric order. For those chapters that have both &#8216;A&#8217; and &#8216;F&#8217; versions of a routine, the routine descriptions are combined into one routine document.  

</div><div class="paramtext">Documentation is provided in the following formats: 
<ul class="listind"><li class="listind"><b>XHTML+MathML</b>, a fully linked version of the manual using XHTML and MathML (recommended for browsing) and providing links to the PDF version of each document (recommended for printing); and</li><li class="listind"><b>PDF</b>, a full PDF manual browsed using the PDF bookmarks, or via HTML index files.</li></ul> 
</div><div class="paramtext">Advice on viewing and navigating the formats available can be found in the document <a class="genint" href="../GENINT/onlinehelp.xml#ONLINEHELP">Online Documentation</a>.</div><div class="paramtext">The most up-to-date version of the documentation is accessible via the NAG <a class="url" href="http://www.nag.com">web site</a> (see <a class="sec" href="#support">Section 5</a>).</div><h3 class="standard"><a class="sec" name="libanddoc5" id="libanddoc5"/>2.3&#160;&#160;Implementations of the Library</h3>
<div class="paramtext">The Library is available on many different computer systems.  For each distinct system, an <b>implementation</b> of the Library is prepared by NAG, e.g., the Sun Solaris 32-bit implementation.  The implementation is distributed to sites as a tested compiled library.</div><div class="paramtext">An implementation is usually specific to a range of machines (e.g., the SPARC systems); it may also be specific to a particular Fortran compiler, or compiler option (such as scalar or vector mode or thread safe).</div><div class="paramtext">Essentially the same facilities are provided in all implementations of the Library, but, because of differences in arithmetic behaviour and in the compilation system, routines cannot be expected to give identical results on different systems, especially for sensitive numerical problems.</div><div class="paramtext">The documentation supports all implementations of the Library, with the help of a few simple conventions, and a small amount of implementation-dependent information, which is published in a separate <b><a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a></b> for each implementation (see <a class="sec" href="#doc4">Section 4.4</a>).</div><h3 class="standard"><a class="sec" name="libanddoc7" id="libanddoc7"/>2.4&#160;&#160;Library Identification</h3>
<div class="paramtext">Periodically a new <b>Mark</b> of the NAG Library is released: new routines are added, corrections and/or improvements are made to existing routines; and occasionally routines are withdrawn if they have been superseded by improved routines.</div><div class="paramtext">You must know <b>which implementation</b>, <b>which precision</b> and <b>which mark</b> of the Library you are using or intend to use.  To find out which implementation, precision and mark of the Library is available at your site, you can run a program which calls the NAG  Library routine <a class="rout" href="../A00/a00aaf.xml">A00AAF</a>.</div><div class="paramtext">The program could be:
<pre class="verbatim">
EXTERNAL A00AAF
CALL     A00AAF()
END
</pre>
</div><div class="paramtext">Alternatively, the example program for <a class="rout" href="../A00/a00aaf.xml">A00AAF</a> can be run using the <span class="mono">nagexample</span> scripts supplied with your implementation (see the <a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a> for details).</div><div class="paramtext">An example of the output is:
<pre class="verbatim">
*** Start of NAG Library implementation details ***

Implementation title: IA32, Linux, Intel Fortran
           Precision: FORTRAN double precision
        Product Code: FLLUX22DC
                Mark: 22

*** End of NAG Library implementation details ***
</pre>
</div><h3 class="standard"><a class="sec" name="libanddoc8" id="libanddoc8"/>2.5&#160;&#160;Fortran Language Standards</h3>
<div class="paramtext">All routines in the Library conform to the ISO Fortran 95 Standard (<a class="ref" href="#ref643">ISO (1997)</a>), except for the use of the double precision complex data type COMPLEX*16.</div><h2 class="standard"><a class="sec" name="library" id="library"/>3&#160;&#160;Using the Library</h2><h3 class="standard"><a class="sec" name="library1" id="library1"/>3.1&#160;&#160;General Advice</h3>
<div class="paramtext">A NAG Library routine <b>cannot</b> be guaranteed to return meaningful results irrespective of the data supplied to it.  Care and thought <b>must</b> be exercised in:
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline">(a)</td>
<td valign="top">formulating the problem;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(b)</td>
<td valign="top">programming the use of library routines;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(c)</td>
<td valign="top">assessing the significance of the results.</td>
</tr></table>
</div><div class="paramtext">The Foreword to the Manual provides some further discussion of points (a) and (c); the remainder of <a class="sec" href="#library">Section 3</a> is concerned with (b).</div><h3 class="standard"><a class="sec" name="library2" id="library2"/>3.2&#160;&#160;Programming Advice</h3>
<div class="paramtext">The Library and its documentation are designed with the assumption that you will write a calling program in Fortran (although it may be called from other languages &#8211; see <a class="sec" href="#library7">Section 3.10</a>).</div><div class="paramtext">When programming a call to a routine, read the routine document carefully, especially the description of the <b>Parameters</b>.  This states clearly which parameters must have values assigned to them on entry to the routine, and which return useful values on exit.  See <a class="sec" href="#doc3">Section 4.3</a> for further guidance.</div><div class="paramtext">The most common types of programming error in using the Library are:
<ul class="listind"><li class="listind">incorrect parameters in a call to a Library routine;</li><li class="listind">calling the Library from a single precision program.</li></ul>
</div><div class="paramtext">Therefore if a call to a Library routine results in an unexpected error message from the system (or possibly from within the Library), <b>check</b> the following:
<ul class="listind"><li class="listind"><b>Has the NAG routine been called with the correct number of parameters?</b></li><li class="listind"><b>Do the parameters all have the correct type?</b></li><li class="listind"><b>Have all array parameters been dimensioned correctly?</b></li><li class="listind"><b>Does your program pass the correct precision parameters to the NAG Library routines?</b></li></ul>
</div><div class="paramtext">Avoid the use of NAG-type names for your own program units or COMMON blocks: in general, do not use names which contain a three-character NAG chapter name embedded in them; they may clash with the names of an auxiliary routine or COMMON block used by the NAG Library.</div><h3 class="standard"><a class="sec" name="library3" id="library3"/>3.3&#160;&#160;Error Handling and the Parameter IFAIL</h3><h4 class="standard"><a class="sec" name="background1" id="background1"/>3.3.1&#160;&#160;Errors, Failure and Warning Conditions</h4>
<div class="paramtext">The error, failure or warning conditions considered here are those that can be detected by explicit coding in a Library routine.  Such conditions must be anticipated by the author of the routine.  They should not be confused with run-time errors detected by the compiling system,  e.g., detection of overflow or failure to assign an initial value to a variable.</div><div class="paramtext">In the rest of this document we use the word &#8216;error&#8217; to cover all types of error, failure or warning conditions detected by the routine.  They fall roughly into three classes.
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline">(i)</td>
<td valign="top">On entry to the routine the value of a parameter is out of range. This means that it is not useful, or perhaps even meaningful, to begin computation.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(ii)</td>
<td valign="top">During computation the routine decides that it cannot yield the desired results, and indicates a failure condition. For example, a matrix inversion routine will indicate a failure condition if it considers that the matrix is singular and so cannot be inverted.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(iii)</td>
<td valign="top">Although the routine completes the computation and returns results, it cannot guarantee that the results are completely reliable; it therefore returns a warning. For example, an optimization routine may return a warning if it cannot guarantee that it has found a local minimum.</td>
</tr></table>
<b>All three classes of errors are handled in the same way by the Library.</b></div><div class="paramtext">Each error which can be detected by a Library routine is associated with a number.  These numbers, with explanations of the errors, are listed in Section 6 (Error Indicators and Warnings) in the routine  document.  Unless the document specifically states to the contrary,  you should not assume that the routine necessarily tests for the occurrence of the errors in their order of error number, i.e., the detection of an error does not imply that other errors have or have not been detected.</div><h4 class="standard"><a class="sec" name="background2" id="background2"/>3.3.2&#160;&#160;The IFAIL Parameter</h4>
<div class="paramtext">Most of the NAG Library routines which can be called directly by you have a parameter called IFAIL.  This parameter is concerned with the NAG Library error trapping mechanism (and, for some routines, with controlling the output of error messages and advisory messages).</div><div class="paramtext">IFAIL has <b>two</b> purposes:
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline"><a name="item1" id="item1"/>(i)</td>
<td valign="top">to allow you to specify what action the Library routine should take if an error is detected;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="item2" id="item2"/>(ii)</td>
<td valign="top">to inform you of the outcome of the call of the routine.</td>
</tr></table>
</div><div class="paramtext">For purpose <a class="item" href="#item1">(i)</a>, you <b>must</b> assign a value to IFAIL before the call to the Library routine.  Since IFAIL is reset by the routine for purpose <a class="item" href="#item2">(ii)</a>, the parameter must be the name of a variable, <b>not</b> a literal or constant.</div><div class="paramtext">The value assigned to IFAIL before entry should be either <m:math><m:mn>0</m:mn></m:math>&#160;(<b>hard fail</b> option), or 1 or &#8211; <m:math><m:mn>1</m:mn></m:math>&#160;(<b>soft fail</b>  option).  If after completing its computation the routine has not detected an error, IFAIL is reset to <m:math><m:mn>0</m:mn></m:math>&#160;to indicate a <b>successful call.</b> Control returns to the calling program in the normal way.  If the routine  does detect an error, its action depends on whether the hard or soft fail option was chosen.</div><h4 class="standard"><a class="sec" name="background3" id="background3"/>3.3.3&#160;&#160;Hard Fail Option</h4>
<div class="paramtext">If you set IFAIL to <m:math><m:mn>0</m:mn></m:math>&#160;before calling the Library routine,  execution of the program will terminate if the routine detects an error.  Before the program is stopped, this error message is output:
<pre class="verbatim">
** ABNORMAL EXIT from NAG Library routine XXXXXX: IFAIL = n
** NAG hard failure - execution terminated
</pre>
where  <span class="mono">XXXXXX</span> is the routine name, and <span class="mono">n</span> is the number associated with the detected error.  An explanation of error number <span class="mono">n</span> is given in Section 6 of the routine document  <span class="mono">XXXXXX</span>.</div><div class="paramtext">In addition, most routines output explanatory error messages immediately before the standard termination message shown above.</div><div class="paramtext">The hard fail option should be selected if you are in any doubt about continuing the execution of the program after an unsuccessful call to a NAG Library routine.  For environments where it might be inappropriate to halt program execution when an error is detected it is recommended that the hard fail option is <b>not</b> used.</div><h4 class="standard"><a class="sec" name="background4" id="background4"/>3.3.4&#160;&#160;Soft Fail Option</h4>
<div class="paramtext">To select this option, you must set IFAIL to <m:math><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>&#160;before calling the Library routine.</div><div class="paramtext">If the routine detects an error, IFAIL is reset to the associated error number; further computation within the routine is suspended and control returns to the calling program.</div><div class="paramtext">If you set IFAIL to <m:math><m:mn>1</m:mn></m:math>, then no error message is output (<b>silent exit</b>).  If the output of error messages is undesirable, then silent exit is recommended.</div><div class="paramtext">If you set IFAIL to <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>&#160;(<b>noisy exit</b>),  then before control is returned to the calling program, the following error message is output:
<pre class="verbatim">
** ABNORMAL EXIT from NAG Library routine XXXXXX: IFAIL = n
** NAG soft failure - control returned
</pre>
In addition, most routines output explanatory error messages immediately before the above standard message.</div><div class="paramtext"><b>It is most important to test the value of IFAIL on exit if the soft fail option is selected.</b>  A nonzero exit value of IFAIL implies that the call was not successful so it is imperative that your program be coded to take appropriate action.  That action may simply be to print IFAIL with an explanatory caption and then terminate the program.  Many of the example programs in Section 9 of the routine documents have IFAIL-exit tests of this form.  In the more ambitious case, where you wish your program to continue, it is essential that the program can branch to a point at which it is <b>sensible</b> to resume computation.</div><div class="paramtext">The soft fail option puts the onus on you to handle any errors detected by the Library routine.  With the proviso that you are able to implement it <b>properly</b>, it is clearly more flexible than the hard fail option since it allows computation to continue in the case of errors.  In particular there are at least two cases where its flexibility is useful:
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline">(i)</td>
<td valign="top">where additional information about the error or the progress of computation is returned via some of the other parameters;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(ii)</td>
<td valign="top">in some routines, &#8216;partial&#8217; success can be achieved, e.g., a probable solution found but not all conditions fully satisfied, so the routine returns a warning. On the basis of the advice in Section 6 and elsewhere in the routine document, you may decide that this partially successful call is adequate for certain purposes.</td>
</tr></table>
</div><h4 class="standard"><a class="sec" name="background5" id="background5"/>3.3.5&#160;&#160;Historical Note</h4>
<div class="paramtext">The error handling mechanism described above was introduced into the NAG Library at Mark 12.  It supersedes the earlier mechanism which for most routines allowed IFAIL to be set by you to <m:math><m:mn>0</m:mn></m:math>&#160;or 1 only.  The new mechanism is compatible with the old except that the details of the messages output on hard failure have changed.  The new mechanism also allows you to set IFAIL to <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>&#160;(soft failure,  noisy exit).</div><div class="paramtext">A few routines (introduced mainly at Marks 7 and 8) use IFAIL in a different way to control the output of error messages, and also of advisory messages (see <a class="chap" href="../X04/x04conts.xml">Chapter X04</a>).  In those routines IFAIL is regarded as a decimal integer whose least significant digits are denoted <m:math><m:mi>b</m:mi><m:mi>a</m:mi></m:math>&#160;with the following significance:
<div class="tablediv"><table class="frame-none">
  
  
  <tbody>
   <tr>
    <td class="libdoc" valign="top" align="left" style="width:12em;"><m:math><m:mi>a</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:math>: hard failure</td>
    <td class="libdoc" valign="top" align="left" style="width:12em;"><m:math><m:mi>a</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:math>: soft failure</td>
   </tr><tr>
    <td class="libdoc" valign="top" align="left" style="width:12em;"><m:math><m:mi>b</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:math>: silent exit</td>
    <td class="libdoc" valign="top" align="left" style="width:12em;"><m:math><m:mi>b</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:math>: noisy exit</td>
   </tr>
  </tbody>
 </table></div>
</div><div class="paramtext">Details are given in the documents of the relevant routines; for those routines this alternative use of IFAIL remains valid.</div><h3 class="standard"><a class="sec" name="library4" id="library4"/>3.4&#160;&#160;Input/output in the Library</h3>
<div class="paramtext">Most NAG Library routines perform no output to an external file, except possibly to output an error message.  All error messages are written to a logical <b>error message</b> unit.  This unit number (which is set by default to 6 in most implementations) can be changed by calling the Library routine <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>.</div><div class="paramtext">Some NAG Library routines may optionally output their final results, or intermediate results to monitor the course of computation.  In general, output other than error messages is written to a logical <b>advisory message</b> unit.  This unit number (which is also set by default to 6 in most implementations) can be changed by calling the Library routine <a class="rout" href="../X04/x04abf.xml">X04ABF</a>.  Although it is logically distinct from the error message unit, in practice the two unit numbers may be the same.  A few routines in <a class="chap" href="../E04/e04conts.xml">Chapter E04</a> allow this unit number to be specified directly as an option.</div><div class="paramtext">All output from the Library is formatted.</div><div class="paramtext">There are only a few Library routines which perform input from an external file.  These examples occur in <a class="chap" href="../E04/e04conts.xml">Chapters E04</a>, <a class="chap" href="../E05/e05conts.xml">E05</a> and <a class="chap" href="../H/hconts.xml">H</a>.  The unit number of the external file is a parameter to the routine, and all input is formatted.</div><div class="paramtext">You must ensure that the relevant Fortran unit numbers are associated with the desired external files, either by an OPEN statement in your calling program, or by operating system commands.</div><h3 class="standard"><a class="sec" name="library5" id="library5"/>3.5&#160;&#160;Auxiliary Routines</h3>
<div class="paramtext">In addition to those Library routines which are documented and are intended to be called by you directly, the Library also contains many auxiliary routines.</div><div class="paramtext">In general, you need not be concerned with them at all, although you may be made aware of their existence if, for example, you examine a memory map of an executable program which calls NAG routines.  The only exception is that when calling some NAG Library routines you may be required or allowed to supply the name of an auxiliary routine from the NAG Library as an external procedure parameter.  The routine documents give the necessary details.  In such cases, you only need to supply the name of the routine; you <b>never</b> need to know details of its parameter list.</div><div class="paramtext">NAG auxiliary routines have names which are similar to the name of the documented routine(s) to which they are related, but with last letter &#8216;Z&#8217;, &#8216;Y&#8217;, and so on, e.g.,
<ul class="listind"><li class="listind">D01BAZ is an auxiliary routine called by <a class="rout" href="../D01/d01baf.xml">D01BAF</a>.</li></ul>
</div><div class="paramtext">A few chapters contain auxiliary routines whose names are obtained by adding 50 to the second and third characters of the chapter name.  For instance, <a class="chap" href="../E04/e04conts.xml">Chapter E04</a> has an auxiliary routine with the name E54NFU which is normally used as the actual argument for the <a class="arg" href="../E04/e04nff.xml#QPHESS">QPHESS</a> parameter of <a class="rout" href="../E04/e04nff.xml">E04NFA</a>; the corresponding name to be used with <a class="rout" href="../E04/e04nff.xml">E04NFF</a> is E04NFU.</div><h3 class="standard"><a class="sec" name="dynamicmemory" id="dynamicmemory"/>3.6&#160;&#160;Dynamic Memory Allocation</h3>
<div class="paramtext">Some NAG Library routines perform dynamic memory allocation to simplify their interfaces.  

Where possible, the amount of memory allocated by a routine will be given in the routine document (usually as a function of routine parameters).
All memory allocated by NAG routines is deallocated before exit.
</div><div class="paramtext">In the case where a routine detects a failure to dynamically allocate sufficient memory, the routine will set an error condition and return by setting <m:math><m:mi mathvariant="normal">IFAIL</m:mi><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>999</m:mn></m:mrow></m:math>, and exit with an appropriate error message.</div><h3 class="standard"><a class="sec" name="licman" id="licman"/>3.7&#160;&#160;License Management</h3>
<div class="paramtext">If your implementation is license managed then your local site will have details on how the license management is implemented; please contact your site installer for details. To determine whether a valid license is available on your machine run the example program for <a class="rout" href="../A00/a00acf.xml">A00ACF</a>.</div><div class="paramtext">Should a valid license not be found when calling license managed routines from the Library then the routine will set an error condition, by setting <m:math>
 <m:mi mathvariant="normal">IFAIL</m:mi><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>399</m:mn></m:mrow>
</m:math>, and exit with an appropriate error message.  The appropriate environment variables should then be checked (e.g., NAG_KUSARI_FILE) to make sure this points to the licence file containing a valid licence, and the licence file should be checked for any obvious errors (e.g., the licence refers to a different implementation).  If everything appears to be correct then please contact <a class="url" href="http://www.nag.co.uk">NAG</a> (see <a class="sec" href="#support">Section 5</a> for details).</div><h3 class="standard"><a class="sec" name="threadsafety" id="threadsafety"/>3.8&#160;&#160;Thread Safety</h3>
<div class="paramtext">Some implementations of the Library facilitate the use of threads; that is, you can call routines from the Library from within a multithreaded application.  Fully thread safe libraries are provided for several platforms &#8212; for more information please contact your local Response Centre (see <a class="sec" href="#support">Section 5</a>).  See the <a class="genint" href="../GENINT/safety.xml#SAFETY">Thread Safety</a> document for more detailed guidance on using the Library in a multithreaded context.  You may also need to refer to the <a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a> for details of whether your implementation of the Library has been compiled in a manner that facilitates the use of threads.</div><div class="paramtext">Note that in some implementations, the Library is linked with one or more vendor libraries to provide, for example, efficient BLAS routines.  NAG cannot guarantee that any such vendor library is thread safe.</div><h3 class="standard"><a class="sec" name="SMPperformance" id="SMPperformance"/>3.9&#160;&#160;Performance on SMP systems</h3>
<div class="paramtext">The introduction of multicore processors and the availability of more affordable multisocket systems mean that SMP systems are increasingly common. Users of the NAG Fortran Library on these systems may benefit directly from any SMP parallelism present in the underlying vendor library (e.g., in BLAS and LAPACK routines), and indirectly via any Library routine which internally uses these parallelised vendor routines. To benefit from this, you should set the appropriate environment variable (usually OMP_NUM_THREADS) to the desired number of threads. Generally this should not be more than the number of available (idle) cores on your system. You should consult the relevant vendor library documentation for further information and contact <a class="url" href="http://www.nag.co.uk">NAG</a> (see <a class="sec" href="#support">Section 5</a> for details) for advice if required.</div><div class="paramtext">The NAG SMP Library is designed to give further benefit on SMP systems. Key Library routines have been explicitly parallelised using <a class="ref" href="#ref836">OpenMP</a> to offer enhanced performance over a wider range of routines compared with the NAG Fortran Library which relies solely on the parallelism in vendor libraries. Further information is given in the <a class="genint" href="../GENINT/smpint.xml#SMPINT">Introduction to the NAG Library for SMP &amp; Multicore</a>.</div><div class="paramtext">Note that the performance increase achieved, if any, will vary depending upon which routine is called, problem sizes and other parameters, system design and operating system configuration. If you frequently call a routine with similar data sizes and other parameters, it may be worthwhile to experiment with different numbers of threads, to determine the choice that gives optimal performance.</div><h3 class="standard"><a class="sec" name="library7" id="library7"/>3.10&#160;&#160;Calling the Library from Other Languages</h3>
<div class="paramtext">In general the NAG Library can be called from other computer languages (such as C and Visual Basic) provided that appropriate mappings exist between their data types.</div><div class="paramtext">NAG has produced C Header Files which comprise of a set of header files, indicating the match between C and Fortran data types for various compilers, documentation and examples.  The documentation, examples and C Header Files are available from the NAG Web sites (see <a class="sec" href="#support">Section 5</a>).</div><div class="paramtext">The Dynamic Link Library (DLL) implementation can be called in a straightforward manner from a number of languages and environments, e.g., Visual Basic, Visual Basic for Applications (Excel), Delphi, C and C++.  Guidance on this is provided as part of NAG Library DLLs.  Further details can be found on the NAG Web sites.</div><h2 class="standard"><a class="sec" name="doc" id="doc"/>4&#160;&#160;Using the Documentation</h2><h3 class="standard"><a class="sec" name="doc1" id="doc1"/>4.1&#160;&#160;Using the Manual</h3>
<div class="paramtext">The Manual is designed to serve the following functions
 for both the NAG Library and the NAG Library for SMP &amp; Multicore:

<ul class="listind"><li class="listind">to give background information about different areas of numerical and statistical computation;</li><li class="listind">to advise on the choice of the most suitable NAG Library routine or routines to solve a particular problem;</li><li class="listind">to give all the information needed to call a NAG Library routine correctly from a Fortran program, and to assess the results.</li></ul>
</div><div class="paramtext">At the beginning of the Manual are some general introductory documents which provide some background and additional information.  
There are a small number of documents which are specific to NAG Library or to the NAG Library for SMP &amp; Multicore, you only need to read those specific to the library you are using.  All other general introductory documents are relevant to both libraries.</div><div class="paramtext">The document entitled &#8216;<a class="genint" href="../GENINT/smpint.xml#SMPINT">Introduction to the NAG Library for SMP &amp; Multicore</a>&#8217; is <span class="bitalic">essential</span> reading for NAG Library for SMP &amp; Multicore users.</div><div class="paramtext">The documents entitled &#8216;<a class="genint" href="../GENINT/news.xml#NEWS">Mark 22 NAG Fortran Library News</a>&#8217; and &#8216;<a class="genint" href="../GENINT/smpnews.xml#SMPNEWS">Mark 22 NAG Library for SMP &amp; Multicore News</a>&#8217; provide 

details of new routines added, details of routines scheduled for withdrawal and details of routines withdrawn at this mark.  
The <a class="genint" href="../GENINT/smpnews.xml#SMPNEWS">Mark 22 NAG Library for SMP &amp; Multicore News</a> also provides details of routines which have been tuned or enhanced at this mark; a full list of such routines is available in the document &#8216;<a class="genint" href="../GENINT/smptuned.xml#SMPTUNED">Tuned and Enhanced Routines in the  NAG Library for SMP &amp; Multicore</a>&#8217;.</div><div class="paramtext">The document entitled &#8216;<a class="genint" href="../GENINT/libconts.xml#LIBCONTS">Library Contents</a>&#8217; (a structured list of routines in the Library, by chapter) may help you to find the chapter, and possibly the routine, which you need to solve your problem.</div><div class="paramtext">The document entitled &#8216;<a class="genint" href="../GENINT/withdrawn.xml#WITHDRAWN">Routines Withdrawn or Scheduled for Withdrawal</a>&#8217; provides full details of all routines withdrawn from the NAG Library and the document entitled &#8216;<a class="genint" href="../GENINT/replace.xml#REPLACE">Advice on Replacement Calls for Withdrawn/Superseded Routines</a>&#8217; provides details of new functionality provided by replacement routines.</div><div class="paramtext">The online documentation provides you with a fully linked HTML <a class="genint" href="../INDEXES/KWIC/kwic.xml#KWIC">Keyword Index</a> (a keyword index to routines) and <a class="genint" href="../INDEXES/GAMS/gams.xml#GAMS">GAMS Classification Index</a> (a list of NAG routines classified according to the GAMS scheme).</div><div class="paramtext">Having found a likely chapter or routine, you should read the corresponding <b>Chapter Introduction,</b> which gives background information about that area of numerical computation, and recommendations on the choice of a routine, including indexes, tables or decision trees.</div><div class="paramtext">When you have chosen a routine, you must consult the <b>routine document</b>.  Each routine document is essentially self-contained (it may, however, contain references to related documents).  It includes a description of the method, detailed specifications of each parameter, explanations of each error exit, remarks on accuracy, and (in most cases) an example program to illustrate the use of the routine.</div><h3 class="standard"><a class="sec" name="doc2" id="doc2"/>4.2&#160;&#160;Structure of Routine Documents</h3>
<div class="paramtext">All routine documents have the same structure consisting of nine numbered sections:
<table class="standard-100"><tr>
<td style="width:2.4em;" valign="baseline"><b>1.</b></td>
<td valign="top"><b>Purpose</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>2.</b></td>
<td valign="top"><b>Specification</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>3.</b></td>
<td valign="top"><b>Description</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>4.</b></td>
<td valign="top"><b>References</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>5.</b></td>
<td valign="top"><b>Parameters</b> (see <a class="sec" href="#doc3">Section 4.3</a> below)</td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>6.</b></td>
<td valign="top"><b>Error Indicators and Warnings</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>7.</b></td>
<td valign="top"><b>Accuracy</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>8.</b></td>
<td valign="top"><b>Further Comments</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>9.</b></td>
<td valign="top"><b>Example</b> (see <a class="sec" href="#doc5">Section 4.5</a> below)</td>
</tr></table>
</div><div class="paramtext">In a few documents (notably <a class="chap" href="../E04/e04conts.xml">Chapters E04</a>, <a class="chap" href="../E05/e05conts.xml">E05</a> and <a class="chap" href="../H/hconts.xml">H</a>) there are a further three sections:
<table class="standard-100"><tr>
<td style="width:2.4em;" valign="baseline"><b>10.</b></td>
<td valign="top"><b>Algorithmic Details</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>11.</b></td>
<td valign="top"><b>Optional Parameters</b></td>
</tr><tr>
<td style="width:2.4em;" valign="baseline"><b>12.</b></td>
<td valign="top"><b>Description of Monitoring Information</b></td>
</tr></table>
</div><h3 class="standard"><a class="sec" name="doc3" id="doc3"/>4.3&#160;&#160;Specification of Parameters</h3>
<div class="paramtext">Section 5 of each routine document contains the specification of the parameters, in the order of their appearance in the parameter list.</div><h4 class="standard"><a class="sec" name="doc31" id="doc31"/>4.3.1&#160;&#160;Classification of parameters</h4>
<div class="paramtext">Parameters are classified as follows.</div><div class="paramtext"><span class="italic">Input</span>: you must assign values to these parameters on or before entry to the routine, and these values are unchanged on exit from the routine.</div><div class="paramtext"><span class="italic">Output</span>: you need not assign values to these parameters before entry to the routine; the routine may assign values to them.</div><div class="paramtext"><span class="italic">Input/Output</span>: you must assign values to these parameters before entry to the routine, and the routine may then change these values.</div><div class="paramtext"><span class="italic">Workspace</span>: array parameters which are used as workspace by the routine.  You must supply arrays of the correct type and dimension.  In general, you need not be concerned with their contents.</div><div class="paramtext"><span class="italic">Communication Array</span>:
 
parameters which are used to communicate data from one routine call to another.</div><div class="paramtext"><span class="italic">External Procedure</span>: a routine which must be supplied (e.g., to evaluate an integrand or to print intermediate output).  Usually it must be supplied as part of your calling program, in which case its specification includes full details of its parameter list and specifications of its parameters (all enclosed in a box).  Its parameters are classified in the same way as those of the Library routine, but because you must write the procedure rather than call it, the significance of the classification is different.
<ul class="listind"><li class="listind"><span class="italic">Input</span>: values may be supplied on entry, which your procedure <b>must not</b> change.</li><li class="listind"><span class="italic">Output</span>: you may or must assign values to these parameters before exit from your procedure.</li><li class="listind"><span class="italic">Input/Output</span>: values may be supplied on entry, and you may or must assign values to them before exit from your procedure.</li></ul>
</div><div class="paramtext">Occasionally, as mentioned in <a class="sec" href="#library5">Section 3.5</a>, the procedure can be supplied from the NAG Library, and then you only need to know its name.</div><div class="paramtext"><span class="italic">User Workspace</span>: array parameters which are passed by the Library routine to an external procedure parameter.  They are not used by the routine, but you may use them to pass information between your calling program and the external procedure.</div><div class="paramtext"><span class="italic">Dummy</span>: a simple variable which is not used by the routine.  A variable or constant of the correct type must be supplied, but its value need not be set. (A dummy parameter is usually a parameter which was required by an earlier version of the routine and is retained in the parameter list for compatibility.)</div><h4 class="standard"><a class="sec" name="doc32" id="doc32"/>4.3.2&#160;&#160;Constraints and suggested values</h4>
<div class="paramtext">The word &#8216;<span class="italic">Constraint</span>:&#8217; or &#8216;<span class="italic">Constraints</span>:&#8217; in the specification of an <span class="italic">Input</span> parameter introduces a statement of the range of valid values for that parameter, e.g.,
<ul class="listind"><li class="listind"><span class="italic">Constraint</span>: <m:math><m:mi mathvariant="normal">N</m:mi><m:mo>&gt;</m:mo><m:mn>0</m:mn></m:math>.</li></ul>
</div><div class="paramtext">If the routine is called with an invalid value for the parameter
(e.g., <m:math><m:mi mathvariant="normal">N</m:mi> <m:mo>=</m:mo> <m:mn>0</m:mn></m:math>), the routine will usually take an error exit, returning a nonzero value of IFAIL (see <a class="sec" href="#library3">Section 3.3</a>).</div><div class="paramtext">Constraints on parameters of type CHARACTER only list upper case alphabetic characters, e.g.,
<ul class="listind"><li class="listind"><span class="italic">Constraint</span>: <m:math><m:mi mathvariant="normal">CHECK</m:mi><m:mo>=</m:mo><m:mtext>'N'</m:mtext></m:math>.</li></ul>
</div><div class="paramtext">In practice, all routines with CHARACTER parameters will permit the use of lower case characters.</div><div class="paramtext">The phrase &#8216;<span class="italic">Suggested Values</span>:&#8217; introduces a suggestion for a reasonable initial setting for an <span class="italic">Input</span> parameter (e.g., accuracy or maximum number of iterations) in case you are unsure what value to use; you should be prepared to use a different setting if the suggested value turns out to be unsuitable for your problem.</div><h4 class="standard"><a class="sec" name="doc33" id="doc33"/>4.3.3&#160;&#160;Array parameters</h4>
<div class="paramtext">Most array parameters have dimensions which depend on the size of the problem.  In Fortran terminology they have &#8216;adjustable dimensions&#8217;: the dimensions occurring in their declarations are integer variables which are also parameters of the Library routine.</div><div class="paramtext">For example, a Library routine might have the specification:
<pre class="verbatim">SUBROUTINE &lt;name&gt; (M, N, A, B, LDB)
INTEGER            M, N, A(N), B(LDB,N), LDB</pre>
</div><div class="paramtext">For a <b>one-dimensional</b> array parameter, such as A in this example, the specification would begin
<ul class="listind"><li class="listind">A(N) &#8211; INTEGER array</li></ul>
</div><div class="paramtext">You must ensure that the dimension of the array, as declared in your calling (sub)program, is at least as large as the value you supply for N.  It may be larger, but the routine uses only the first N elements.</div><div class="paramtext">For a <b>two-dimensional</b> array parameter, such as B in the example, the specification might be
<ul class="listind"><li class="listind">B(LDB,N) &#8211; INTEGER array</li><li class="listind"><span class="italic">On entry</span>: the <m:math><m:mi>m</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;matrix <m:math><m:mi>B</m:mi></m:math>.</li></ul>
and the parameter LDB might be described as follows:
<ul class="listind"><li class="listind">LDB &#8211; INTEGER</li><li class="listind"><span class="italic">On entry</span>: the first dimension of the array B as declared in the (sub)program from which &lt;name&gt; is called.</li><li class="listind"><span class="italic">Constraint</span>: <m:math><m:mi mathvariant="normal">LDB</m:mi> <m:mo>&#8805; </m:mo><m:mi mathvariant="normal">M</m:mi></m:math>.</li></ul>
</div><div class="paramtext">You <b>must</b> supply the <b>first</b> dimension of the array B, as declared in your calling (sub)program, through the parameter LDB, even though the number of rows actually used by the routine is determined by the parameter M.  You must ensure that the first dimension of the array is at least as large as the value you supply for M.  The extra parameter LDB is needed because 
Fortran 77

does not allow information about the dimensions of array parameters to be passed automatically to a routine.</div><div class="paramtext">You must also ensure that the <b>second</b> dimension of the array, as declared in your calling (sub)program, is at least as large as the value you supply for N.  It may be larger, but the routine uses only the first N columns.</div><div class="paramtext">A program to call the hypothetical routine used as an example in this section might include the statements:
<pre class="verbatim">INTEGER AA(100), BB(100,50)
LDB = 100
.
.
.
M = 80
N = 20
CALL &lt;name&gt;(M,N,AA,BB,LDB)</pre>
</div><div class="paramtext">Many NAG routines contain array parameters declared with the &#8216;assumed size&#8217; array dimension, and would be given as
<pre class="verbatim">INTEGER        A(*), B(LDB,*)</pre>
</div><div class="paramtext">However, the original declaration of an array in your calling program must always have constant dimensions, greater than or equal to the minimum value documented.</div><div class="paramtext">Consult an expert or a textbook on Fortran if you have difficulty in calling NAG routines with array parameters.</div><h3 class="standard"><a class="sec" name="doc4" id="doc4"/>4.4&#160;&#160;Implementation-dependent Information</h3>
<div class="paramtext">In order to support all implementations of the Library, the Manual has adopted a convention of using <span class="bitalic">bold</span>
<span class="bitalic">italics</span> to distinguish terms which have different interpretations in different implementations.</div><div class="paramtext">The most important bold italicised terms and their usual interpretation are as follows:
<table class="standard-100"><tr>
<td style="width:13.5em;" valign="baseline"><span class="bitalic">real</span></td>
<td valign="top">means REAL</td>
</tr><tr>
<td style="width:13.5em;" valign="baseline"><span class="bitalic">double precision</span></td>
<td valign="top">means DOUBLE PRECISION</td>
</tr><tr>
<td style="width:13.5em;" valign="baseline"><span class="bitalic">complex</span></td>
<td valign="top">means COMPLEX</td>
</tr><tr>
<td style="width:13.5em;" valign="baseline"><span class="bitalic">complex*16</span></td>
<td valign="top">means COMPLEX*16 (or equivalent)</td>
</tr><tr>
<td style="width:13.5em;" valign="baseline"><span class="bitalic">basic precision</span></td>
<td valign="top">means double precision</td>
</tr><tr>
<td style="width:13.5em;" valign="baseline"><span class="bitalic">additional precision</span></td>
<td valign="top">means quadruple precision</td>
</tr><tr>
<td style="width:13.5em;" valign="baseline"><span class="bitalic">reduced precision</span></td>
<td valign="top">means single precision</td>
</tr></table>
</div><div class="paramtext">Another important bold italicised term is <span class="bitalic">machine precision</span>, which denotes the relative precision to which <span class="bitalic">double precision</span> floating-point numbers are stored in the computer, e.g., in an implementation with approximately 16 decimal digits of precision, <span class="bitalic">machine precision</span> has a value of approximately <m:math><m:msup><m:mn>10</m:mn><m:mn>-16</m:mn></m:msup></m:math>.</div><div class="paramtext">The precise value of <span class="bitalic">machine precision</span> is given by the routine <a class="rout" href="../X02/x02ajf.xml">X02AJF</a>.  Other routines in <a class="chap" href="../X02/x02conts.xml">Chapter X02</a> return the values of other implementation-dependent constants, such as the overflow threshold, or the largest representable integer.  Refer to the <a class="chapint" href="../X02/x02intro.xml">X02 Chapter Introduction</a> for more details.</div><div class="paramtext">The bold italicised term <span class="bitalic">block size</span> is used only in <a class="chap" href="../F07/f07conts.xml">Chapters F07</a> and <a class="chap" href="../F08/f08conts.xml">F08</a>.  It denotes the block size used by block algorithms in these chapters.  You only need to be aware of its value when it affects the amount of workspace to be supplied &#8211; see the parameters WORK and LWORK of the relevant routine documents and the Chapter Introduction.</div><div class="paramtext">In <a class="chap" href="../F06/f06conts.xml">Chapters F06</a>, <a class="chap" href="../F07/f07conts.xml">F07</a> and <a class="chap" href="../F08/f08conts.xml">F08</a>, alternate routine names are available for BLAS and LAPACK derived routines. For details of the alternate routine names please refer to the relevant Chapter Introduction.</div><div class="paramtext">For each implementation of the Library, a separate <b><a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a></b> is published.  This is a short document, revised at each mark.  At most installations it is available in machine-readable form.  It gives any necessary additional information which applies specifically to that implementation, in particular:
<ul class="listind"><li class="listind">the interpretation of bold italicised terms;</li><li class="listind">the values returned by <a class="chap" href="../X02/x02conts.xml">Chapter X02</a> routines;</li><li class="listind">the default unit numbers for output (see <a class="sec" href="#library4">Section 3.4</a>).</li></ul>
</div><h3 class="standard"><a class="sec" name="doc5" id="doc5"/>4.5&#160;&#160;Example Programs and Results</h3>
<div class="paramtext">The <b>example program</b> in Section 9 of most routine documents illustrates a simple call of the routine.  The programs are designed so that they can be fairly easily modified, and so serve as the basis for a simple program to solve your problem.</div><div class="paramtext">For each implementation of the Library, NAG distributes the example programs in machine-readable form, with all necessary modifications already applied.  Many sites make the programs accessible to you in this form.  Generic forms of the programs, without implementation-specific modifications, may be obtained directly from the NAG Web site.  The <a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a> for your implementation will mention any special changes which need to be made to the example programs.</div><div class="paramtext">These example programs contain a number of preprocessor identifiers such as <span class="mono">NAG_CALL</span> and <span class="mono">NAG_IFMT</span> to enable cross platform portability.  These identifiers are subsequently replaced by appropriate implementation specific tokens via the header files <span class="mono">nag.h</span> or <span class="mono">nag_types.h</span>, using the C preprocessor #defines.</div><div class="paramtext">Note that the results obtained from running the example programs may not be identical in all implementations, and may not agree exactly with the results in the Manual which were obtained from a double precision implementation (with approximately 16 digits of precision).</div><div class="paramtext">For many routine documents, a plot of the example program results is also provided.  In some cases the example program has been modified slightly to produce larger sets of results to give a more representative plot of the solution profile produced.</div><h2 class="standard"><a class="sec" name="support" id="support"/>5&#160;&#160;Support from NAG</h2>
<div class="paramtext"><b>NAG Response Centres</b></div><div class="paramtext">The NAG Response Centres are available for general enquiries from all users and also for technical queries from sites that subscribe to the support service.</div><div class="paramtext">The Response Centres are open during office hours, but contact is possible by fax, email and telephone (answering machine) at all times.  Please see the <a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a> or the NAG <a class="url" href="http://www.nag.com">web site</a> for contact details.</div><div class="paramtext">When contacting one of the NAG Response Centres, it helps us to deal with your query quickly if you can quote your NAG user reference and NAG product code.</div><div class="paramtext"><b>NAG Web Site</b></div><div class="paramtext">The NAG <a class="url" href="http://www.nag.com">web site</a> is an information service providing items of interest to users and prospective users of NAG products and services.  The information is regularly updated and reviewed, and includes implementation availability, descriptions of products, downloadable software, case studies, industry articles and technical reports.  The NAG <a class="url" href="http://www.nag.com">web site</a> can be accessed via: <ul class="listind"><li class="listind"><a class="url" href="http://www.nag.co.uk">NAGUK</a></li><li class="listind"><a class="url" href="http://www.nag.com">NAG North America</a></li><li class="listind"><a class="url" href="http://www.nag-j.co.jp">NAG Japan</a></li></ul></div><h2 class="standard"><a class="sec" name="further" id="further"/>6&#160;&#160;Background to NAG</h2>
<div class="paramtext">Various aspects of the design and development of the NAG Library, and NAG's technical policies and organisation are given in <a class="ref" href="#ref227">Ford (1982)</a>, <a class="ref" href="#ref228">Ford <span class="italic">et al.</span> (1979)</a>, <a class="ref" href="#ref229">Ford and Pool (1984)</a>, and <a class="ref" href="#ref230">Hague <span class="italic">et al.</span> (1982)</a>.</div><h2 class="standard"><a class="sec" name="references" id="references"/>7&#160;&#160;References</h2><div class="paramtext"><a name="ref226" id="ref226"/>ACM  (1960&#8211;1976)  Collected algorithms from ACM index by subject to algorithms </div>
<div class="paramtext"><a name="ref546" id="ref546"/>ANSI  (1966)  USA standard Fortran <i>Publication X3.9</i> American National Standards Institute </div>
<div class="paramtext"><a name="ref232" id="ref232"/>ANSI  (1978)  American National Standard Fortran <i>Publication X3.9</i> American National Standards Institute </div>
<div class="paramtext"><a name="ref721" id="ref721"/>ANSI/IEEE POSIX  (1995)  POSIX Standard Thread Library ANSI/IEEE POSIX 1003.1c:1995 </div>
<div class="paramtext"><a name="ref227" id="ref227"/>Ford B (1982)  Transportable numerical software <i>Lecture Notes in Computer Science</i> <b>142</b> 128&#8211;140 Springer&#8211;Verlag </div>
<div class="paramtext"><a name="ref228" id="ref228"/>Ford B, Bentley J, Du Croz J J and Hague S J (1979)  The NAG Library &#8216;machine&#8217; <i>Softw. Pract. Exper.</i> <b>9 (1)</b> 65&#8211;72 </div>
<div class="paramtext"><a name="ref229" id="ref229"/>Ford B and Pool J C T (1984)  The evolving NAG Library service <i>Sources and Development of Mathematical Software</i> (ed W Cowell) 375&#8211;397 Prentice&#8211;Hall </div>
<div class="paramtext"><a name="ref230" id="ref230"/>Hague S J, Nugent S M and Ford B (1982)  Computer-based documentation for the NAG Library <i>Lecture Notes in Computer Science</i> <b>142</b> 91&#8211;127 Springer&#8211;Verlag </div>
<div class="paramtext"><a name="ref643" id="ref643"/>ISO  (1997)  ISO Fortran 95 programming language (ISO/IEC 1539&#8211;1:1997) </div>
<div class="paramtext"><a name="ref701" id="ref701"/>ISO/IEC  (1990)  Information technology &#8211; Programming Language C <i>Current C Language Standard</i> ISO/IEC 9899:1990 </div>
<div class="paramtext"><a name="ref702" id="ref702"/>Kernighan B W and Ritchie D M (1988)  <i>The C Programming Language</i> (2nd Edition) Prentice&#8211;Hall </div>
<div class="paramtext"><a name="ref836" id="ref836"/>OpenMP  <i>The OpenMP specification for parallel programming</i> <a class="url" href="http://www.openmp.org">http://www.openmp.org</a></div><hr/><div><a class="genint" href="../../pdf/GENINT/essint.pdf">Essential Introduction (PDF version)</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>
