In addition, NAG recommends that before calling any Library routine you should read the following reference material from the Library Manual (see Section 5):
(a) How to Use the NAG Library and its Documentation
(b) Chapter Introduction
(c) Routine Document
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.3.3 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. FLDLL26DE_mkl.lib/FLDLL26DE_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 library, FLDLL26DE_nag.lib/FLDLL26DE_nag.dll, is also supplied. This contains the NAG versions of the BLAS and LAPACK routines.
The version of Intel MKL supplied is multithreaded. 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.
Alternatively, set the environment variable to the number of threads required. Note that the Chapter X06 routines do not change the behaviour of MKL threading in serial implementations of the Library.
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.11.1 of How to Use the NAG Library and its Documentation 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.
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\FL26\fldll26del(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\FL26\fldll26delinstead.) 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 shortcut for the Library command prompt is in the NAG Fortran Library (FLDLL26DEL) section of the Start Menu or All apps under:
NAG FLDLL26DEL 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.)
You will need to ensure that the NAG DLL (FLDLL26DE_mkl.dll or FLDLL26DE_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.3.3\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 may be 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 or All apps shortcut
Check NAG FLDLL26DEL DLL AccessibilitySee Section 4.2.2 of the Installer's Note for details of this utility.
NAG FLDLL26DEL 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_FLDLL26DEL, 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\FL26\fldll26del\batch\envvars.batIf this file is not in the default location, you can locate it by searching for the file envvars.bat containing fldll26del.
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 FLDLL26DE_mkl.lib ifort /iface:cvf /MD driver.f90 FLDLL26DE_nag.libwhere driver.f90 is your application program. These 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 (FLDLL26DE_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 (FLDLL26DE_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 (FLDLL26DE_nag.dll). The option /MD should be used to ensure linking with the correct run-time libraries.
/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.
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.3.3\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 (Ctrl+F5), 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.
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 in the NAG Fortran Library (FLDLL26DEL) section of the Start Menu or All apps under
Calling NAG FLDLL26DEL 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.
cl driver.c FLDLL26DE_mkl.libor
cl driver.c FLDLL26DE_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 FLDLL26DE_mkl.libor
cl /I"install_dir\c_headers" driver.c FLDLL26DE_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 2015. 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 FLDLL26DE_mkl.lib or FLDLL26DE_nag.lib to the Additional Dependencies field. Then select Configuration Properties | Linker | General and add install_dir\lib to the Additional Library Directories field. You will also need to either add nagmk26.h to the Header Files section of the Solution Explorer or add the c_headers directory to the C/C++ | General | Additional Include Directories field on the Properties form.
Note that, with Microsoft C++, you may need to use the /EHsc compiler switch with the command line C++ examples.
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.
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 -abi=32 -ieee=full -compatible -I"install_dir\nag_interface_blocks_nagfor" driver.f90 "install_dir\lib\FLDLL26DE_mkl.lib" -o driver.exe nagfor -abi=32 -ieee=full -compatible -I"install_dir\nag_interface_blocks_nagfor" driver.f90 "install_dir\lib\FLDLL26DE_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 FLDLL26DE_mkl or FLDLL26DE_nag library file must be specified and must be enclosed within quotes if it contains spaces.
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/content/calling-nag-fortran-library-dll-csharp.
You may also be interested in the NAG Library for .NET – see http://www.nag.co.uk/content/nag-library-net for details.
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.
This has been tested using Microsoft Office Excel 2010, 2013 and 2016.
This has been tested using Visual Studio 2010, 2012, 2013 and 2015.
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
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, where FCOMP is the name of your Fortran compiler: (N.B. you will also need to add the /iface:cvf switch if FCOMP is the Intel Fortran compiler, ifort, and probably similar flags for other compilers, in order to get the correct calling convention)
FCOMP -c nag_precisions.f90 FCOMP -c nag_a_ib.f90 FCOMP -c nag_blast_ib.f90 FCOMP -c nag_blas_consts.f90 FCOMP -c nag_blas_ib.f90 FCOMP -c nag_c_ib.f90 FCOMP -c nag_d_ib.f90 FCOMP -c nag_e_ib.f90 FCOMP -c nag_f_ib.f90 FCOMP -c nag_g_ib.f90 FCOMP -c nag_h_ib.f90 FCOMP -c nag_lapack_ib.f90 FCOMP -c nag_m_ib.f90 FCOMP -c nag_s_ib.f90 FCOMP -c nag_x_ib.f90 FCOMP -c nag_long_names.f90 FCOMP -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 FLDLL26DE_mkl.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_FLDLL26DEL 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 e04nrfwill copy the example program and its data and options files (e04nrfe.f90, e04nrfe.d and e04nrfe.opt) into the current folder, compile and link the program and run it to produce the example program results in the file e04nrfe.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 e04nrf
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 How to Use the NAG Library and its Documentation 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.
In this implementation calls to the NAG version of the following BLAS and LAPACK routines are included in the libraries FLDLL26DE_mkl.dll to avoid problems with the vendor version:
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/content/nag-fortran-library-manual.
The Library Manual is supplied in the following formats:
The following main index files have been provided for these formats:
nagdoc_fl26\html\frontmatter\manconts.html nagdoc_fl26\pdf\frontmatter\manconts.pdf nagdoc_fl26\pdf\frontmatter\manconts.htmlIf the Library Manual has been installed locally, these index files are available from the NAG Mark 26 Manual section of the Start Menu or All apps under
NAG Library Manual Mark 26 (HTML5) NAG Library Manual Mark 26 (PDF) NAG Library Manual Mark 26 (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
Advice on viewing and navigating the formats available can be found in http://www.nag.co.uk/numeric/fl/nagdoc_fl26/html/genint/essint.html.
The Library Manual is also available as an HTML Help file, which is available from http://www.nag.co.uk/content/nag-fortran-library-manual.
In addition the following are provided:
NAG FLDLL26DEL Users' Noteby default.
for information about the NAG Technical Support Service, including details of the NAG Technical Support Service contact points. We would also be delighted to receive your feedback on NAG's products and services.
for worldwide contact details for the Numerical Algorithms Group.