The NAG Fortran DLLs

Supplied Materials

When you purchase a DLL you will also receive:

  • A small selection of test programs to test successful installation
  • C and C++ header files, to assist you in mapping data types and for 'cut and paste' usage
  • Visual Basic (VB) 'Declare statements' to facilitate the usage from VB6 and Microsoft Excel
  • Visual Basic (VB) 'Declare statements' to facilitate the usage from VB.NET
  • Fortran 90 Interface blocks to enable Fortran 90 programmers to conveniently insert interface blocks for the NAG routines into their programs
  • A Windows HTML Help version of the NAG routine documentation
  • Skeletal 'jacket' routines, written in Fortran. These provide a mechanism for providing subroutine or function arguments to a NAG routine from the VB6 or Excel environment

Please Note: At Mark20 NAG offer two distinct Fortran DLL products. One is compiled with default options and is not thread safe; the other has been compiled with thread safe options and has a thread safe subset library. All routines in this subset are thread safe.


When you purchase the NAG DLLs from us, you are provided with a copy of the full Fortran Library manual in PDF format; printed documentation can be purchased separately. The manual is the principal form of documentation for the library. 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 PDF manual. General introductory documents and indexes can be found at the beginning of the manual.

Each chapter has an introduction, giving a general background to the types of problem that can be solved, and guidance on selecting the most suitable routines. There is also a list of contents and then a routine document for each documented routine in the chapter.

For users of the DLLs Windows HTML Help documentation is also provided. This is useful for package builders who can link directly to the help file. Additionally, files are provided to allow Visual Basic Declare Statements and C Header file information and Fortran 90 interface blocks to be cut and pasted into user programs.

Using the Help File

The user may call the Help file directly from the Start menu.

System developers may wish to use the NAG Help file within their own applications. To do this effectively they will need to be aware of the Context IDs used within the help file. This is based upon the routine name and is calculated by the following VB Function:

Function ContextID (RoutineName As String) As Long
RoutineName = LCase$(RoutineName)
Dim ID As Double
Dim a As Double, b As Double, c As Double, d As Double
a = (Asc(Mid$(RoutineName, 1, 1)) - 97)
b = CDbl(Mid$(RoutineName, 2, 2))
c = (Asc(Mid$(RoutineName, 4, 1)) - 97)
d = (Asc(Mid$(RoutineName, 5, 1)) - 97)
ID = a * 2 * 26 * 26 * 26# + _
b * 2 * 26 * 26# + _
c * 2 * 26# + _
d * 2#
ContextID = ID End Function

Mathematically this assigns the integer value ContextID to



a = ASCII value of the first letter (converted if necessary to lowercase) of the routine name - 97
b = numerical value of the next two digits of the routine name
c = ASCII value of the fourth letter (converted if necessary to lowercase) of the routine name - 97
d = ASCII value of the fifth letter (converted if necessary to lowercase) of the routine name - 97

For example the ContextID of routine E04NCF is 146696. This is calculated as follows:

ContextID = 2x26³a+2x26²b+2x26c+2d,


a = (101-97) = 4
b = (04) = 4
c = (110-97) = 13
d = (99-97) = 2

By adding 1 to the ContextID for a routine the application developer may obtain the ContextID for the Error Exits associated with that routine.

Table of ASCII Values

a 97 b 98 c 99 d 100
e 101 f 102 g 103 h 104
i 105 j 106 k 107 l 108
m 109 n 110 o 111 p 112
q 113 r 114 s 115 t 116
u 117 v 118 w 119 x 120
y 121 z 122