High Performance Computing Virtual Laboratory - NAG libraries
http://www.hpcvl.org/taxonomy/term/43/0
This is an introduction on the HPCVL installation of the Numerical Algorithms Group (NAG) libraries and associated software. The NAG libraries are a large collection of numerical routines ranging from the implementation of complex arithmetic to time series analysis. Parts of the routines are suitable for execution on both shared-memory and distributed-memory parallel computers. The documentation of the library is extensive, and this FAQ is only meant as a basic introduction to its use on HPCVL computers.enWhat are the "NAG Libraries"?
http://www.hpcvl.org/faqs/application-software/nag-libraries/what-is-the-nag-libraries
<p>The Numerical Algorithms Group mathematical libraries are on of the most extensive and widely used collection of numerical and mathematical routines available. They have become a standard due to their portability, reliability and stability. The libraries offer both serial and parallel versions of a variety of numerical algorithms, ranging from complex arithmetic, quadrature and the numerical solution of differential equations to linear algebra, eigenvalue problems and nonlinear optimization. The routines are extensively documented and equipped with error-trapping and reporting systems.</p><p>The libraries are available both as static archives and dynamic shared-object files. They can be used from Fortran and C programs. Which versions of the NAG software are currently in use in HPCVL machines?</p><p>The current versions of the NAG software on HPCVL machines are:</p><p>C Libraries Mark 8,<br />F90 Libraries Release 4,<br />SMP Libraries Release 21,<br />Parallel Libraries Release 3<br />Iris Explorer Release 5.0</p><p>These versions are the latest releases as of September 2006. The libraries will be updated as newer releases become available. Note that some routines from earlier versions have been withdrawn. NAG supplies a list of those routines and suggestions as to how to replace them.</p>NAG librariesTue, 14 Jun 2011 14:33:52 +0000High Performance Computing Virtual Laboratory255 at http://www.hpcvl.orgWhere do the Libraries Reside?
http://www.hpcvl.org/faqs/application-software/nag-libraries/where-do-the-libraries-reside
<p>Like most "optional" software on SUN systems, the libraries are located in the /opt directory hierarchy. The directory root is:</p><pre>/opt/nag/</pre><p>The different library distributions are located in the directories</p><pre>clsol08dcl clso608dcl explorer flso621dcl flsol21dcl fnso604db<br />fnsol04dcl fsso621dcl fsso621dcl license</pre><p>"explorer" contains the Iris Explorer visualization software, "license" contains the license file and manager, and the other directories contain various libraries.</p><h3>How do I Setup my Environment to use NAG?</h3><p>For the libraries, no special setup is required. The required routines are just linked to the software by the standard -l option to the compiler (linker). However, usage of programs that were linked to the NAG libraries requires a valid license to be present on the system. To this end a license file needs to be located by the license manager.</p><p>For the HPCVL SunFire Cluster, this license file is</p><pre>/opt/nag/license/license.dat</pre><p>Some of the libraries require a separate license file called</p><pre>/opt/nag/license/kusari.dat</pre><p>If you intend to run programs that use the NAG libraries or the accompanying software, you should set the environment variables LM_LICENSE_FILE and NAG_KUSARI_FILE in your setup files to enable the license managers to find the above files.</p><p>For csh or tcsh add this line in your .cshrc or .tcshrc file:</p><pre>setenv LM_LICENSE_FILE /opt/nag/license/license.dat setenv NAG_KUSARI_FILE<br />/opt/nag/license/kusari.dat</pre><p>For ksh, bash, etc add this line in your in .profile or .bashrc:</p><pre>LM_LICENSE_FILE=/opt/nag/license/license.dat; export<br />LM_LICENSE_FILE NAG_KUSARI_FILE=/opt/nag/license/kusari.dat; export NAG_KUSARI_FILE</pre><p>Alternatively, you may leave the setup for the NAG libraries to the usepackage facility, and simply type</p><pre>use nag</pre><p>from your command prompt, or include this command in your setup files (.login or .profile).</p><p>Using the Iris Explorer requires the execution of additional setup files, which will be <a href="http://hpcvl.org/faqs/application-software/iris-visualization-software">discussed elsewhere.</a></p>NAG librariesTue, 14 Jun 2011 14:35:44 +0000High Performance Computing Virtual Laboratory256 at http://www.hpcvl.orgHow is NAG Software Licensed?
http://www.hpcvl.org/faqs/application-software/nag-libraries/how-is-the-nag-software-licensed
<p>HPCVL has a <a href="/sites/default/files/hpvcl_nag_license.pdf?phpMyAdmin=fec4e5f8403t4839c515">license agreement </a>with the Numerical Algorithms Group. This license allows programs that use the NAG libraries to be executed on our machines without restrictions on the number of such processes, or the number of CPU's involved. The license is not node-locked or limited by seats.</p><p>We do require our users to <a href="/sites/default/files/hpvcl_nag_statement.pdf?phpMyAdmin=fec4e5f8403t4839c515">sign and return a statement </a>to the effect that they will abide by the terms of the license agreement. Once we receive this statement, we will enter you into a "nag" Unix group and you can access the libraries and license.</p><p>The presence of a valid license is checked at runtime. This means that a license manager is automatically invoked everytime a program using the NAG routines is executed. This license manager will then check the system for a presence of a license file which uniquely identifies the machine. If such a file exists the execution continues, if not, a message is issued and execution is terminated.</p><p>Our agreement with NAG includes the unique opportunity for HPCVL users to <a href="http://nag.com/downloads/downloads_entry.asp">download and use the NAG</a> libraries and software on their own workstations. Individual license keys will be required for this, and will be issued by us on a temporary basis on request. The validity of the license key is limited by the duration of our agreement with NAG, and of your access with HPCVL. Within these terms, you can freely use the libraries on an arbitrary number of machines. The software itself may be downloaded directly from the NAG website.</p>NAG librariesTue, 14 Jun 2011 14:43:10 +0000High Performance Computing Virtual Laboratory257 at http://www.hpcvl.orgWhat serial Libraries are there?
http://www.hpcvl.org/faqs/application-software/nag-libraries/what-serial-libraries-are-there
<p>The original NAG Library was coded in FORTRAN and not intended for use with multiple processors. The NAG Fortran Library is still the basic library anc includes essentially all available routines in a serial form. Note however, that the implementation of these routines has been greatly modified from earlier versions, and that they are largely "thread safe", i.e., although designed for sequential run in themselves, may be used in combination with multi-threaded (i.e. Parallel-enabled) programs without danger of interference.</p><p>At this point the library routines are available in three largely equivalent forms:</p><ul><li>The NAG Fortran Library is compatible with Standard Fortran77</li><li>The NAG F90 Library uses the extended Fortran 95 Standard</li><li>The NAG C Library is written in ANSI C</li></ul>NAG librariesTue, 14 Jun 2011 14:43:57 +0000High Performance Computing Virtual Laboratory258 at http://www.hpcvl.orgWhat features do the serial libraries have?
http://www.hpcvl.org/faqs/application-software/nag-libraries/what-features-do-the-serial-libraries-have
<p>It is not possible to give a complete listing of the library features in this FAQ. For a listing, please consult the documentation, which is available in PDF format, at the NAG documentation website, and in hardcopy at our Princess St. Office in Kingston.</p><p>Here we can only give a basic list of the more important features:</p><ul><li>Complex Arithmetic</li><li>Roots of polynomials and transcendental equations</li><li>Series Summation and quadrature</li><li>Fourier Series and Transforms</li><li>Ordinary and partial differential equations</li><li>Numerical Differentiation</li><li>Interpolation</li><li>Fitting of curves and sufaces</li><li>Optimization</li><li>Linear Algebra: Matrices, Determinants, Eigenvalues, Linear Equation Systems, Least-Squares, Orthogonalization, Sparse systems</li><li>Statistics: Correlation, Regression, Variance Analysis,Univariate estimations, Nonparametric statistics, Smoothing, Contingency tables, Time series, Uni- and multivariate estimations</li><li>Random numbers</li><li>Operations Research</li><li>Sorting</li><li>Special Functions</li></ul>NAG librariesTue, 14 Jun 2011 14:44:54 +0000High Performance Computing Virtual Laboratory259 at http://www.hpcvl.orgHow do I use the NAG Fortran Library?
http://www.hpcvl.org/faqs/application-software/nag-libraries/how-do-i-use-the-nag-fortran-library
<p>The Fortran Library is used by directly linking the static or dynamic versions of the library to the program that uses it. Other libraries should be used in conjunction with it, such as socket or intl. The libraries and auxilliary files reside in /opt/nag/flsol20dal. The following lines are typical for a compilation with the NAG libraries:</p><p><strong>Compiling:</strong></p><pre>f90 -c -dalign -mt program.f</pre><p><strong>Linking (static):</strong></p><pre>f90 -o program.exe -dalign -mt -lsocket -lnsl -lintl -xlic_lib=sunperf \<br />program.o /opt/nag/flsol21dcl/lib/libnag_spl.a</pre><p><strong>Linking (dynamic):</strong></p><pre>f90 -o program.exe -dalign -mt -lsocket -lnsl -lintl -xlic_lib=sunperf \<br />program.o -Bdynamic -R/opt/nag/flsol21dcl/lib -L/opt/nag/flsol21dcl/lib -lnag_spl</pre><p>Note that the <em>-dalign</em> option is necessary to avoid bus errors. The <em>nsl</em>, <em>intl</em>, and <em>socket</em> libraries are necessary only in some cases, but it is recommended to include them in the link list. The version of the Fortran library used in the above compilation/linking lines makes use of the <em>Sun Performance Library</em> (spl) for optimized execution of basic mathematical operations. It is recommended to use this version on the SunFire cluster of HPCVL. It is also recommended to use the f90 compiler, since it is the one that is supported by Sun.</p><p>For the actual usage of the routines in the library, a large number of example programs are available in<em>/opt/nag/flsol21dcl/examples/source</em>. They should be consulted together with the documentation. The routines do not require any header files or special setup, but can be used directly. Routines should be declared<em>EXTERNAL</em> in most cases. A simple example is</p><pre>A02ACF divides one complex number x=(a,b) by another y=(c,d) to yield a third z=(e,f)</pre><p>To use the routine, all that needs to be done is declaring a,b,c,d,e,f as DOUBLE PRECISION and call it.</p><pre>DOUBLE PRECISION A,B,C,D,E,F EXTERNAL A02ACF ... CALL A02ACF(A,B,C,D,E,F) ...</pre>NAG librariesTue, 14 Jun 2011 14:47:48 +0000High Performance Computing Virtual Laboratory260 at http://www.hpcvl.orgHow do I use the NAG F90 Library?
http://www.hpcvl.org/faqs/application-software/nag-libraries/how-do-i-use-the-nag-f90-library
<p>The NAG F90 library is a completely rewritten version of the Fortran library and uses the Fortran 90 extension of Fortran on all levels. For instance, array operations make use of the extended abilities of Fortran 90, and all programs have a modular structure. The libraries are only available as static archives, and reside in<em>/opt/nag/fnsol04dcl</em>.</p><p>One consequence of the Fortran 90 modular program structure is that data and methods residing in modules need to be compiled before they are available for other Fortran routines via the use command. All the modules needed for use with the NAG F90 library reside in <em>/opt/nag/fnsol04dcl/nagfl90_modules</em>. Here is a typical set of compile/link calls:</p><p><strong>Compiling:</strong></p><pre>f90 -c -dalign -M/opt/nag/fnsol04dcl/nagfl90_modules program.f90</pre><p><strong>Linking (static):</strong></p><pre>f90 -o program.exe -dalign -M/opt/nag/fnsol04dcl/nagfl90_modules \<br />-lsocket -lnsl -lintl -xlic_lib=sunperf program.o /opt/nag/fnsol04dcl/lib/libnagfl90_spl.a </pre><p><strong>Linking (dynamic):</strong></p><pre>f90 -o program.exe -dalign -M/opt/nag/fnsol04dcl/nagfl90_modules \<br />-lsocket -lnsl -lintl -xlic_lib=sunperf program.o \ -Bdynamic -L/opt/nag/fnsol04dcl/lib \<br />-R/opt/nag/fnsol04dcl/lib -lnagfl90_spl </pre><p>The <em>-M</em> option in the above lines serves to let the compiler/linker know where the module files associated with the F90 library reside.</p><p>Examples for the usage of the F90 libraries may be found in <em>/opt/nag/fnsol04dcl/examples/source</em>. There is a considerable difference in the way the F90 library is used from its Fortran counterpart. One diference is the usage of modules. For instance, the routine nag_gen_lin_sol solves systems of linear equations and requires the use of several modules:</p><pre>PROGRAM test USE nag_examples_io, ONLY : nag_std_in, nag_std_out USE nag_gen_lin_sys,<br />ONLY : nag_gen_lin_sol (...) INTRINSIC KIND (...) REAL (wp),<br />ALLOCATABLE :: a(:,:), b(:) (...) READ (nag_std_in,*) READ (nag_std_in,*) n<br />READ (nag_std_in,*) trans ALLOCATE (a(n,n),b(n)) READ (nag_std_in,*) (a(i,:),i=1,n)<br />READ (nag_std_in,*) b CALL nag_gen_lin_sol(a,b,trans=trans,bwd_err=bwd_err,<br />fwd_err=fwd_err,rcond=rcond) (...) DEALLOCATE (a,b) END PROGRAM nag_gen_lin_sys_ex01 </pre><p>Note that the array a in the above example is dynamically allocated and needs to be deallocated at the end of the program. I/O occurs with units that are defined in modules. The intrinsic function kind has to be declared as such and is used to determine the type of a given variable.</p>NAG librariesTue, 14 Jun 2011 14:48:38 +0000High Performance Computing Virtual Laboratory261 at http://www.hpcvl.orgHow do I use the NAG C Library?
http://www.hpcvl.org/faqs/application-software/nag-libraries/how-do-i-use-the-nag-c-library
<p>The C Library is used by directly linking the static or dynamic versions of the library to the program that uses it. Other libraries should be used in conjunction with it, such as socket or intl. The library resides in /opt/nag/clsol07dal. The following lines are typical for a compilation with the NAG libraries:</p><p><strong>Compiling:</strong></p><pre>cc -c -dalign -I/opt/nag/clsol08dcl/include program.c</pre><p><strong>Linking (static):</strong></p><pre>cc -o program.exe -dalign -lm -lsocket -lnsl -lintl -xlic_lib=sunperf -lsunmath \<br />program.o /opt/nag/clsol08dcl/lib/libnagc_spl.a</pre><p><strong>Linking (dynamic):</strong></p><pre>cc -o program.exe -dalign -lm -lsocket -lnsl -lintl -xlic_lib=sunperf -lsunmath program.o \<br />-Bdynamic -R/opt/nag/clsol08dcl/lib -L/opt/nag/clsol08dcl/lib -lnagc_spl</pre><p>This is assuming that you want to use the Sun Performance Libraries from within the NAG routines. If you prefer the generic routines (making the code slower, but more portable), replace the reference to <em>nagc_spl</em> by<em>nagc_nag</em> and drop the <em>-xlic_lib=sunperf</em> option.</p><p>Note that the <em>-dalign</em> option is necessary to avoid bus errors. The <em>nsl</em>, <em>intl</em>, and <em>socket</em> libraries are necessary only in some cases, but it is recommended to include them in the link list. Make sure that <em>cc</em> actually refers to Sun native C-compiler and not to another compiler that might reside on the system and be prefered by your<em>PATH</em> setting. You can check by typing "<em>which cc</em>" which should yield the response "<em>/opt/studio12/SUNWspro/bin/cc</em>" or similar.</p><p>The NAG C-Library requires some programming conventions that are best determined from the documentation. Header files need to be included, and as seen in the example above, the <em>-I</em> option should be used to point the compiler to the directory where they reside (<em>/opt/nag/clsol08dcl/include</em>). Several of the routines that are<em>SUBROUTINE</em>s in the Fortran version of the NAG library are <em>function</em>s in the C-version. The names may differ as well. A simple example is</p><pre>a02cdc divides one complex number x=(a,b) by another y=(c,d) to yield a third z=(e,f)</pre><p>The involved numbers need to be declared Complex in the C program, which requires the header files nag.h and naga02.h to be included.</p><pre>#include #include #include #include int main(void) ... double a,b,c,d,e,f;<br />Complex x,y,z; ... x=a02bac(a,b); y=a02bac(c,d) z=a02cdc(x,y) e=z.re; f=z.im ... </pre><p>In this case, we used the routine a02bac to assign real and imaginary parts to a Complex number, and the convention <em>z.re</em> and <em>z.im</em> to extract the real and imaginary parts from a Complex number (which is a <em>structure</em>in C).</p><p>For details about the usage of specific program, consult the programming examples in<em>/opt/nag/clsol08dcl/examples/source</em> in conjunction with the documentation.</p>NAG librariesTue, 14 Jun 2011 14:49:35 +0000High Performance Computing Virtual Laboratory262 at http://www.hpcvl.orgWhat parallel NAG libraries are there?
http://www.hpcvl.org/faqs/application-software/nag-libraries/what-parallel-nag-libraries-are-there
<p>The parallel NAG libraries consist of two contributions, namely</p><ul><li>The NAG Parallel Library which uses MPI to implement scalable versions of numerical operations that lend themselves for parallel execution. This library will typically be used on a cluster. Presently, we do not have this library installed on our machines, as it requires a deprecated component (the S3L libraries) of <em>Sun ClusterTools</em>.</li><li>The NAG Fortran SMP Library which uses Symmetric Multiprocessor machines for numerical operations that can make use of multiple processors (real or virtual). This library will typically be used on a shared-memory multiprocessor machine.</li></ul>NAG librariesTue, 14 Jun 2011 14:50:25 +0000High Performance Computing Virtual Laboratory263 at http://www.hpcvl.orgWhat features do the parallel NAG libraries have?
http://www.hpcvl.org/faqs/application-software/nag-libraries/what-features-do-the-parallel-nag-libraries-have
<p>Note that not all of the features of the serial libraries are suitable for execution on multiprocessor machines or clusters. Therefore the scope of the NAG Parallel Library is smaller than the one of the serial ones. The Fortran SMP Library, however, is identical in content to the NAG Fortran Library, making migration from one to the other almost trivial. What features do the parallel libraries have?</p><p>The Parallel Library focusses strongly on linear algebra operations, where the arrays in question (matrices and vectors) may be distributed among processors. A few additional features (such as Fourier Transforms) are supplied as well. Here is a basic list of features:</p><ul><li>Summation of Series: 1,2, and 3-D Fourier transforms</li><li>One- and multi-dimensional numerical quadrature</li><li>Minimization of functions using only functional evaluations</li><li>Basic Matrix operations and distribution</li><li>Eigenvalues and Eigenvectors and Singular-Value Decomposition</li><li>Linear Equation Systems, partly based on ScaLAPACK</li><li>Least-Square Problems (based on ScaLAPACK)</li><li>Sparse Linear Algebra</li><li>Random Number Generators suitable for distributed systems</li></ul><p>The SMP Library has a much wider scope than the Parallel Library, but is limited in its scaling properties. It is optimized for making use of multiple processors on a single machine without an excessive use of communication. Features are outlined above under the NAG Fortran Library, with which it is functionally identical.</p>NAG librariesTue, 14 Jun 2011 14:51:14 +0000High Performance Computing Virtual Laboratory264 at http://www.hpcvl.org