In addition, NAG recommends that before calling any Library routine you should read the following reference material (see Section 5):
(a) Essential Introduction
(b) Chapter Introduction
(c) Routine Document
http://www.nag.co.uk/doc/inun/fl25/dll4ml/supplementary.html
for details of any new information related to the applicability or usage of this implementation.
This implementation of the NAG Fortran Library provides static and shared libraries that use a third-party vendor performance library to provide Basic Linear Algebra Subprograms (BLAS) and Linear Algebra PACKage (LAPACK) routines (see below). It also provides static and shared libraries that use the NAG versions of these routines (referred to as the self-contained libraries).
This implementation of the NAG Fortran Library has been tested with version 11.2.1 of the Intel ® Math Kernel Library for Windows (MKL) which is supplied as a part of this product. Please see the Intel website for further information about MKL (https://software.intel.com/intel-mkl).
For best performance, we recommend that you use a variant of the NAG Fortran Library which is based on the supplied MKL, i.e. FLDLL254M_mkl.lib/FLDLL254M_mkl.dll. These libraries do not contain the NAG versions of the BLAS and LAPACK routines (except for any routines listed in Section 4(a)).
The self-contained libraries, nag_nag_MT.lib, nag_nag_MD.lib and FLDLL254M_nag.lib/FLDLL254M_nag.dll, are also supplied. These contain the NAG versions of the BLAS and LAPACK routines.
Which static variant of the NAG Library you should use will also depend on how you wish to link to the Microsoft run-time libraries. For example, if you are linking with the multithreaded static run-time libraries, you should use nag_mkl_MT.lib or nag_nag_MT.lib, whereas if you are linking with the multithreaded dynamic link run-time libraries, you should use nag_mkl_MD.lib or nag_nag_MD.lib. Alternatively, if you wish to call a dynamic link library (DLL) variant of the NAG Library, you should link with the import library FLDLL254M_mkl.lib or FLDLL254M_nag.lib (and, at run time, make sure that the corresponding DLL, FLDLL254M_mkl.dll or FLDLL254M_nag.dll, is on your path). For more details, see Section 3.1.1.
The libraries supplied with this implementation have been compiled in a manner that facilitates the use of multiple threads.
With the version of Intel MKL supplied, if the environment variable OMP_NUM_THREADS is undefined, MKL may create multiple threads to speed up computation on systems with more than one processor or a multicore chip. If you do not want MKL to make use of multiple cores or processors, OMP_NUM_THREADS must be set to 1.
Intel have introduced a conditional bitwise reproducibility (BWR) option in MKL. Provided a user's code adheres to certain conditions (see https://software.intel.com/en-us/node/528579), BWR can be forced by setting the MKL_CBWR environment variable. See the MKL documentation for further details. It should be noted, however, that many NAG routines do not adhere to these conditions. This means that for a given NAG library built on top of MKL, it may not be possible to ensure BWR for all NAG routines across different CPU architectures by setting MKL_CBWR. See Section 3.13 of the Essential Introduction for more general information on bitwise reproducibility.
This implementation of the NAG Library is appropriate for use with the compilers described in Section 2.1 of the Installer's Note. Although it contains DLL versions of the NAG Library these are not intended for use from other packages and environments such as Visual Basic or Excel; see the supplementary information page on our website (described in Section 2 above) for further details.
The NAG Fortran Library has been built using the version of Intel Fortran described in the Installer's Note, Section 2.2. Some required Intel Fortran compiler run-time DLLs are available in the install_dir\rtl\bin folder, and you may or may not need to have that folder on your path at program run time, depending on whether or not you have the Intel Fortran compiler installed elsewhere and which version it is.
In this section we assume that the Library has been installed in the default folder, namely
C:\Program Files\NAG\FL25\fldll254ml(Note that if a 32-bit library is installed on a 64-bit machine, the default location will actually be
C:\Program Files (x86)\NAG\FL25\fldll254mlinstead.) The actual name of the "Program Files" folder may appear differently, depending on your locale. If the above folder does not exist, please consult the system manager (or the person who did the installation). In some of the following subsections, this folder is referred to as install_dir.
We also assume that the default shortcut for the Library command prompt is placed in Start Menu/All apps under:
NAG FLDLL254M Command PromptIf this shortcut does not exist, please consult the system manager (or the person who did the installation). (Other shortcuts created as part of the Library installation procedure are also assumed to be in this location.)
If you are using one of the DLL forms of the Library (see Section 3.1.1), you need to ensure that the NAG DLL (FLDLL254M_mkl.dll or FLDLL254M_nag.dll) is accessible at run time; therefore the install_dir\bin folder must be on the path. The install_dir\rtl\bin folder must be on the path too (unless you have the appropriate Intel run-time libraries on your path already). If an MKL-based version of the Library is to be used, the install_dir\mkl_ia32_11.2.1\bin folder must also be on the path, but should appear later in the path than the install_dir\bin folder, since the NAG versions of a few BLAS / LAPACK routines are included in the NAG Libraries to avoid problems with the vendor versions. (See Section 4 for details.)
To check the accessibility of the NAG DLLs, run the program NAG_Fortran_DLL_info.exe which is available from the Start Menu/All apps shortcut
Check NAG FLDLL254M DLL AccessibilitySee Section 4.2.2 of the Installer's Note for details of this utility.
The shortcut:
NAG FLDLL254ML Command Promptmay be used to start a command prompt window with the correct settings for the INCLUDE, LIB and PATH environment variables for the Library and the supplied MKL. The environment variable NAG_FLDLL254ML, which is needed by the nag_example_*.bat batch files is also set.
If the shortcut is not used, you can set the environment variables by running the batch file envvars.bat for this implementation. The default location for this file is:
C:\Program Files\NAG\FL25\fldll254ml\batch\envvars.batIf this file is not in the default location, you can locate it by searching for the file envvars.bat containing fldll254ml.
You may then compile and link to the NAG Fortran Library on the command line using one of the following commands.
ifort /iface:cvf /MD driver.f90 FLDLL254M_mkl.lib ifort /iface:cvf /MD driver.f90 FLDLL254M_nag.libwhere driver.f90 is your application program.
The last two commands use DLL import libraries compiled with the /MD option. The difference between the two is that the former will use the DLL without the NAG version of the BLAS/LAPACK procedures (FLDLL254M_mkl.dll) in addition to the MKL DLLs. It is not necessary to add the path to the MKL import libraries here, since the BLAS and LAPACK symbols are exported from the NAG import library (FLDLL254M_mkl.lib) in this instance. (Note that this behaviour may be different from some other NAG Library implementations.) The last command will use the DLL containing the NAG version of the BLAS/LAPACK procedures (FLDLL254M_nag.dll). The option /MD should be used to ensure linking with the correct run-time libraries.
Note that
/MD is equivalent to specifying
Please note that the Intel Visual Fortran compiler environment variables must be set in the command window. For more details refer to the Users' Guide for the compiler.
In addition, note that if your installation of the Intel Fortran compiler is associated with Visual Studio 2015 or later then, because of the way that compiler run-time libraries have been reorganised, you may also need to link to the Microsoft library legacy_stdio_definitions.lib by adding it to the end of the compilation lines shown above.
When you installed the NAG Library, if you allowed the installer to update your environment variables, then changes will already have been made to your PATH, LIB and INCLUDE variables which allow Visual Studio to locate various NAG interface block files and libraries at compile time and run time. Otherwise, to ensure that the NAG DLLs are accessible at run time, the PATH environment variable must be set such that the location of the NAG DLLs, specifically the folder install_dir\bin, is on the path. If the MKL version of the DLL is required, the location of the MKL DLLs, install_dir\mkl_ia32_11.2.1\bin must also be on the path, but should appear after the install_dir\bin folder.
The library is intended to be run in fully optimized mode, so to avoid any warning messages, you might decide to set the active configuration to Release. Once Visual Studio has been opened, you can do this from the Toolbar or alternatively via the Build|Configuration Manager menus. Note that if you work in Debug mode, you may receive a warning message about conflicting run-time libraries.
The following steps show how to add the NAG Library to the Intel Fortran project:
If you are running on a 64-bit system, make sure the Target CPU is set to x86 (to ensure compatibility with this 32-bit implementation of the NAG Library). The project should now compile and link using the appropriate choice from the Build menu.
To run a program from within the Microsoft Development Environment, the program may be executed via the Debug menu (by selecting Start Without Debugging, for example).
If a data file needs to be attached to the standard input or the output of a program needs to be redirected to the standard output, this can be achieved by selecting the Debugging section on the Properties form and inserting the appropriate commands in the Command Arguments field, e.g.
< input_file > output_fileIf the input and output files are not in the application's working directory, full or relative paths may need to be specified. For NAG examples that use an .opt file, this should be placed in the working directory. This directory may be set via the Working Directory field, which is also on the Debugging page of the Properties form. (Note that input / output redirection is broken in some versions of Visual Studio 2008.)
From a Windows command prompt, first make sure that the PATH environment variable is correctly set, as described in Section 3.1.1.
You may then compile and link to the NAG Fortran Library on the command line using one of the following commands:
nagfor -compatible -I"install_dir\nag_interface_blocks_nagfor" driver.f90 "install_dir\lib\FLDLL254M_mkl.lib" -o driver.exe nagfor -compatible -I"install_dir\nag_interface_blocks_nagfor" driver.f90 "install_dir\lib\FLDLL254M_nag.lib" -o driver.exedepending on whether you wish to link to the MKL-supported version of the library or the all-NAG version.
The full pathname of the FLDLL254M_mkl or FLDLL254M_nag library file must be specified and must be enclosed within quotes if it contains spaces.
Using the DLLs from within the Fortran Builder IDE itself is also easy, following steps like these:
Note that if you build your project in Debug mode (the default), it is not possible to use the Undefined variables option which is accessible on the Fortran Compiler / Runtime Check tab of Project Settings. This is because the NAG Library was not compiled with this option. Trying to use it will cause a compile-time error in Fortran Builder, showing an "Incompatible option setting" when using the NAG interface blocks.
Examples of the use of the DLLs from C# are given in the install_dir\samples\cs_examples folder. At a command line prompt, these can easily be compiled using the C# compiler csc like this:
csc /platform:x86 driver.cswhere driver.cs is the name of any of the example programs.
For further information, see also http://www.nag.co.uk/numeric/csharpinfo.asp.
You may also be interested in the NAG Library for .NET – see http://www.nag.co.uk/microsoft_dotnet.asp for details.
Examples of the use of the DLLs from C and C++ are given in the install_dir\samples\c_examples and install_dir\samples\cpp_examples folders.
A document, techdoc.html, giving more detailed advice on calling the DLLs from C and C++ is available in install_dir\c_headers. There is also a shortcut to this document on the Start Menu under
Start|All Programs|NAG|FL25|NAG Fortran Library (FLDLL254ML)| Calling NAG FLDLL254ML from C & C++by default. Note that some changes will be needed if you paste code from one of the C examples given there into a C++ file since, if __cplusplus is defined, the header file provided uses C++ reference arguments for scalars, and therefore the "address of" operator should not be used. See Section 3 of the techdoc.html document for more details.
Key information:
cl driver.c FLDLL254M_mkl.libor
cl driver.c FLDLL254M_nag.libwhere driver.c is your application program. This assumes that the folder containing the header file has been added to the INCLUDE environment variable. If not, you could use:
cl /I"install_dir\c_headers" driver.c FLDLL254M_mkl.libor
cl /I"install_dir\c_headers" driver.c FLDLL254M_nag.lib
The Intel C compiler icl may be used in the same way as the Microsoft compiler cl, though it may not be necessary to add the rtl\lib directory to your LIB environment variable.
The following instructions apply to Visual Studio 2010 and Visual Studio 2012. Other versions may vary.
If you are working under the Visual Studio IDE, set the following values to enable linking to work. Under the project's Properties, select Configuration Properties | Linker | Input and add FLDLL254M_mkl.lib or FLDLL254M_nag.lib to the Additional Dependencies field. If the LIB environment variable has not been set elsewhere, select Configuration Properties | Linker | General and add install_dir\lib to the Additional Library Directories field.
Note that, with Microsoft C++, you may need to use the /EHsc compiler switch with the command line C++ examples.
Examples of use of the DLLs from within Excel are given in the install_dir\samples\excel_examples folder. The folder install_dir\samples\excel_examples\linear_algebra contains the file xls_demo.html. This file gives some hints about using NAG DLLs from within Excel spreadsheets. See also the VB 6 examples for further illustrations of calling the NAG DLLs from VB 6 / VBA.
Key information:
This has been tested using Microsoft Office Excel 2003, 2007 and 2010.
Examples of use of the DLLs from Visual Basic 6 are given in the install_dir\samples\vb6_examples folder. See also the VBA code within the Excel examples for further illustrations of calling the NAG DLLs from VB 6 / VBA.
Key information:
This has been tested using Microsoft Visual Basic 6.0.
Key information:
Imports System.Runtime.InteropServices
This has been tested using Visual Studio .NET 2003, 2005, 2008 and 2010.
If running on a 64-bit system, it may be necessary to set the Target CPU to x86 to avoid a BadImageFormatException.
However, it is very much easier to use the NAG Library for Java.
(a) subroutines are called as such;
(b) functions are declared with the right type;
(c) the correct number of arguments are passed; and
(d) all arguments match in type and structure.
The NAG Fortran Library interface block files are organised by Library chapter. They are aggregated into one module named
nag_library
The modules are supplied in pre-compiled form (.mod files) for use by the Intel Fortran compiler, ifort.
If you use the Library command prompt shortcut or set the environment variables by running the batch file envvars.bat for this implementation (see Section 3.1.1), and the Intel ifort compiler, you can use any of the commands described in Section 3.1.1 to access these modules since the environment variable INCLUDE will be set.
The .mod module files were compiled with the compiler shown in Section 2.2 of the Installer's Note. Such module files are compiler-dependent, so if you wish to use the NAG example programs, or use the interface blocks in your own programs, when using a compiler that is incompatible with these modules, you will first need to create your own module files, as described here.
Create a folder named nag_interface_blocks_original in a location of your choice (the exact folder name is not important), and copy the contents of nag_interface_blocks to nag_interface_blocks_original, thus saving the original set of interface blocks.
Then in folder nag_interface_blocks recompile all the .f90 files into objects using your compiler. Because the interface blocks contain some inter-dependencies, the order of compilation is important, but the following compilation order should work:
ifort /iface:cvf -c nag_precisions.f90 ifort /iface:cvf -c nag_a_ib.f90 ifort /iface:cvf -c nag_blast_ib.f90 ifort /iface:cvf -c nag_blas_consts.f90 ifort /iface:cvf -c nag_blas_ib.f90 ifort /iface:cvf -c nag_c_ib.f90 ifort /iface:cvf -c nag_d_ib.f90 ifort /iface:cvf -c nag_e_ib.f90 ifort /iface:cvf -c nag_f_ib.f90 ifort /iface:cvf -c nag_g_ib.f90 ifort /iface:cvf -c nag_h_ib.f90 ifort /iface:cvf -c nag_lapack_ib.f90 ifort /iface:cvf -c nag_m_ib.f90 ifort /iface:cvf -c nag_s_ib.f90 ifort /iface:cvf -c nag_x_ib.f90 ifort /iface:cvf -c nag_long_names.f90 ifort /iface:cvf -c nag_library.f90The object files generated by the compilation may be discarded - only the module files are needed.
You should now be able to use the newly compiled module files in the usual way.
The distributed example results are those obtained with the library nag_mkl_MD.lib (i.e. using the MKL BLAS and LAPACK routines). Running the examples with NAG BLAS or LAPACK may give slightly different results.
Note that the example material has been adapted, if necessary, from that published in the Library Manual, so that programs are suitable for execution with this implementation with no further changes. The distributed example programs should be used in preference to the versions in the Library Manual wherever possible.
The example programs are most easily accessed using the batch file nag_example_DLL.bat, which can be found in the install_dir\batch folder. The batch file will provide you with a copy of an example program (and its data, if any), compile the program and link it with the appropriate libraries (showing you the compile command so that you can recompile your own version of the program). Finally, the executable program will be run, with the results being sent to a file and to the command window.
The batch file requires that the environment variables for your Fortran compiler and the NAG Fortran Library are set. In particular, the environment variable NAG_FLDLL254ML needs to be set to the location of the NAG Fortran Library. Please see Section 3.1.1 for details of how to do this.
The example program concerned is specified by the argument to the command, e.g.
nag_example_DLL e04ucfwill copy the example program and its data and options files (e04ucfe.f90, e04ucfe.d and e04ucfe.opt) into the current folder, compile and link the program and run it to produce the example program results in the file e04ucfe.r.
nag_example_DLL.bat links to the DLL version of the NAG Library using NAG BLAS/LAPACK.
To link with the MKL version of the DLL, use the -mkl option, e.g.
nag_example_DLL -mkl e04ucf
This implementation of the NAG Fortran Library uses 32-bit integers.
The NAG Library and documentation use parameterized types for floating-point variables. Thus, the type
REAL(KIND=nag_wp)appears in documentation of all NAG Fortran Library routines, where nag_wp is a Fortran KIND parameter. The value of nag_wp will vary between implementations, and its value can be obtained by use of the nag_library module. We refer to the type nag_wp as the NAG Library "working precision" type, because most floating-point arguments and internal variables used in the library are of this type.
In addition, a small number of routines use the type
REAL(KIND=nag_rp)where nag_rp stands for "reduced precision type". Another type, not currently used in the library, is
REAL(KIND=nag_hp)for "higher precision type" or "additional precision type".
For correct use of these types, see almost any of the example programs distributed with the Library.
For this implementation, these types have the following meanings:
REAL (kind=nag_rp) means REAL (i.e. single precision) REAL (kind=nag_wp) means DOUBLE PRECISION COMPLEX (kind=nag_rp) means COMPLEX (i.e. single precision complex) COMPLEX (kind=nag_wp) means double precision complex (e.g. COMPLEX*16)
In addition, the Manual has adopted a convention of using bold italics to distinguish some terms. See Section 4.4 of the Essential Introduction for details.
Alternatively, run the diagnostic program NAG_Fortran_DLL_info.exe which itself calls A00AAF (see Installer's Note, Section 4.2.2).
Many LAPACK routines have a "workspace query" mechanism which allows a caller to interrogate the routine to determine how much workspace to supply. Note that LAPACK routines from the MKL may require a different amount of workspace from the equivalent NAG versions of these routines.
The behaviour of functions in these Chapters may depend on implementation-specific values.
General details are given in the Library Manual, but the specific values used in this implementation are as follows:
S07AAF F_1 = 1.0E+13 F_2 = 1.0E-14 S10AAF E_1 = 1.8715E+1 S10ABF E_1 = 7.080E+2 S10ACF E_1 = 7.080E+2 S13AAF x_hi = 7.083E+2 S13ACF x_hi = 1.0E+16 S13ADF x_hi = 1.0E+17 S14AAF IFAIL = 1 if X > 1.70E+2 IFAIL = 2 if X < -1.70E+2 IFAIL = 3 if abs(X) < 2.23E-308 S14ABF IFAIL = 2 if X > x_big = 2.55E+305 S15ADF x_hi = 2.65E+1 S15AEF x_hi = 2.65E+1 S15AGF IFAIL = 1 if X >= 2.53E+307 IFAIL = 2 if 4.74E+7 <= X < 2.53E+307 IFAIL = 3 if X < -2.66E+1 S17ACF IFAIL = 1 if X > 1.0E+16 S17ADF IFAIL = 1 if X > 1.0E+16 IFAIL = 3 if 0 < X <= 2.23E-308 S17AEF IFAIL = 1 if abs(X) > 1.0E+16 S17AFF IFAIL = 1 if abs(X) > 1.0E+16 S17AGF IFAIL = 1 if X > 1.038E+2 IFAIL = 2 if X < -5.7E+10 S17AHF IFAIL = 1 if X > 1.041E+2 IFAIL = 2 if X < -5.7E+10 S17AJF IFAIL = 1 if X > 1.041E+2 IFAIL = 2 if X < -1.9E+9 S17AKF IFAIL = 1 if X > 1.041E+2 IFAIL = 2 if X < -1.9E+9 S17DCF IFAIL = 2 if abs(Z) < 3.92223E-305 IFAIL = 4 if abs(Z) or FNU+N-1 > 3.27679E+4 IFAIL = 5 if abs(Z) or FNU+N-1 > 1.07374E+9 S17DEF IFAIL = 2 if AIMAG(Z) > 7.00921E+2 IFAIL = 3 if abs(Z) or FNU+N-1 > 3.27679E+4 IFAIL = 4 if abs(Z) or FNU+N-1 > 1.07374E+9 S17DGF IFAIL = 3 if abs(Z) > 1.02399E+3 IFAIL = 4 if abs(Z) > 1.04857E+6 S17DHF IFAIL = 3 if abs(Z) > 1.02399E+3 IFAIL = 4 if abs(Z) > 1.04857E+6 S17DLF IFAIL = 2 if abs(Z) < 3.92223E-305 IFAIL = 4 if abs(Z) or FNU+N-1 > 3.27679E+4 IFAIL = 5 if abs(Z) or FNU+N-1 > 1.07374E+9 S18ADF IFAIL = 2 if 0 < X <= 2.23E-308 S18AEF IFAIL = 1 if abs(X) > 7.116E+2 S18AFF IFAIL = 1 if abs(X) > 7.116E+2 S18DCF IFAIL = 2 if abs(Z) < 3.92223E-305 IFAIL = 4 if abs(Z) or FNU+N-1 > 3.27679E+4 IFAIL = 5 if abs(Z) or FNU+N-1 > 1.07374E+9 S18DEF IFAIL = 2 if REAL(Z) > 7.00921E+2 IFAIL = 3 if abs(Z) or FNU+N-1 > 3.27679E+4 IFAIL = 4 if abs(Z) or FNU+N-1 > 1.07374E+9 S19AAF IFAIL = 1 if abs(X) >= 5.04818E+1 S19ABF IFAIL = 1 if abs(X) >= 5.04818E+1 S19ACF IFAIL = 1 if X > 9.9726E+2 S19ADF IFAIL = 1 if X > 9.9726E+2 S21BCF IFAIL = 3 if an argument < 1.583E-205 IFAIL = 4 if an argument >= 3.765E+202 S21BDF IFAIL = 3 if an argument < 2.813E-103 IFAIL = 4 if an argument >= 1.407E+102
The values of the mathematical constants are:
X01AAF (pi) = 3.1415926535897932 X01ABF (gamma) = 0.5772156649015328
The values of the machine constants are:
The basic parameters of the model
X02BHF = 2 X02BJF = 53 X02BKF = -1021 X02BLF = 1024
Derived parameters of the floating-point arithmetic
X02AJF = 1.11022302462516E-16 X02AKF = 2.22507385850721E-308 X02ALF = 1.79769313486231E+308 X02AMF = 2.22507385850721E-308 X02ANF = 2.22507385850721E-308
Parameters of other aspects of the computing environment
X02AHF = 1.42724769270596E+45 X02BBF = 2147483647 X02BEF = 15
The Library Manual is available as a separate installation, via download from the NAG website. The most up-to-date version of the documentation is accessible via the NAG website at http://www.nag.co.uk/numeric/fl/fldocumentation.asp.
The Library Manual is supplied in the following formats:
The following main index files have been provided for these formats:
nagdoc_fl25\html\frontmatter\manconts.html nagdoc_fl25\pdf\frontmatter\manconts.pdf nagdoc_fl25\pdf\frontmatter\manconts.htmlIf the Library Manual has been installed locally, these index files are available from Start Menu/All apps under
NAG Library Manual Mark 25 (HTML5) NAG Library Manual Mark 25 (PDF) NAG Library Manual Mark 25 (PDF + HTML Index)respectively, by default. Use your web browser to navigate from here. For convenience, a master index file containing links to the above files has been provided at
nagdoc_fl25\index.html
Advice on viewing and navigating the formats available can be found in the Online Documentation document.
The Library Manual is also available as an HTML Help file, which is available from Start Menu/All apps under
NAG Library Manual Mark 25 HTML HelpIf the NAG Library materials have been installed on a network drive, you may need to copy the HTML Help file (nagdoc_fl25.chm) to a local drive. If you still have trouble seeing the correct help file materials, e.g. if you see a message such as
Navigation to the webpage was canceledthe file might have been blocked by security updates in Windows or Internet Explorer. Right-click on nagdoc_fl25.chm in Windows Explorer and select Properties from the pop-up menu. If there is an Unblock button at the bottom click on it to unblock the file and then click on OK to close the Properties dialog box.
In addition the following are provided:
NAG FLDLL254M Users' Noteby default.
www.nag.co.uk/content/nag-technical-support-service
for information about the NAG Technical Support Service, including details of the NAG Technical Support Service contact points. We would also be delighted to received your feedback on NAG's products and services.
http://www.nag.co.uk/content/worldwide-contact-information
for worldwide contact details for the Numerical Algorithms Group.