NAG Fortran Library, Mark 19

FLDLL194Z

Windows 95/98/NT Dynamic Link Libraries (32-bit)

(Compaq Visual Fortran)

Users' Note



Contents


1. Introduction

This document is essential reading for every user of the NAG Fortran Library Implementation specified in the title. It provides implementation-specific detail that augments the information provided in the NAG Fortran Library on-line documentation (PDF files) and in the NAG Fortran Library Introductory Guide. Wherever these refer to the "Users' Note for your implementation", you should consult this note.

NAG recommends that you read the following minimum reference material before calling any library routine:

(a) Essential Introduction
(b) Chapter Introduction
(c) Routine Document
(d) Implementation-specific Users' Note

Items (a), (b) and (c) are included in the NAG Fortran Library on-line documentation; items (a) and (b) are also included in the NAG Fortran Library Introductory Guide; item (d) is this document which is provided in HTML form.

2. Availability of Routines

All routines listed in the chapter contents of the NAG Fortran Library on-line documentation, Mark 19, are available in this implementation. At Mark 19, 68 new primary ("user-callable") routines have been introduced, and 15 deleted. Please consult the document "Mark 19 News" in the on-line documentation for lists of these routines and for a list of routines scheduled for withdrawal at Mark 20 or later. Your suggestions for new algorithms for future releases of the Library are welcomed (see Section 8).

3. Restrictions

The library has been implemented for single thread use only. Moreover, as DLLs, this implementation cannot be used with the Compaq Visual Fortran compiler to link to QuickWin or Standard Graphics Applications. A different implementation of the NAG Fortran Library, Mark 19 (product code FLW3219DD) is available for this purpose.

Because of difficulties associated with passing channel numbers between a main program and a DLL, the option setting routines E04DJF, E04MGF, E04NDF, E04NGF, E04NLF, E04UDF, E04UHF and E04UQF have been altered slightly in their specification. Please see Section 5.1 for further details.

The default Compaq Visual Fortran calling convention is used. In essence this means that parameters are accessed by reference. Character strings are passed by reference followed immediately by the value of the length of the string. (This will be of interest mainly to C and C++ users; see Section 4.4.)

4. General Information

4.1. Accessing the Library

The libraries are installed in the DLL subdirectory of the chosen installation directory. If the user has cannot access these DLLs for any reason, then check that the DLL subdirectory is on the PATH and that a re-boot has been performed if the autoexec.bat has been modified during installation.

There are 22 self-contained DLLs which together make up the whole of the Mark 19 Fortran Library. The individual DLLs contain a chapter or group of chapters of the NAG library as detailed below:

DLL         Chapters
 
NAGAC       A00, A02, C02, C05, C06
NAGD01      D01
NAGD02      D02
NAGD03      D03
NAGD045     D04, D05
NAGE012     E01, E02
NAGE04      E04
NAGF01      F01
NAGF02      F02
NAGF0345    F03, F04, F05
NAGF06      F06
NAGF07      F07
NAGF08      F08
NAGF11      F11
NAGG01      G01
NAGG02      G02
NAGG034     G03, G04
NAGG05      G05
NAGG0712    G07, G08, G10, G11, G12
NAGG13      G13
NAGHMP      H, M01, P01
NAGSX       S01, S09, S10, S11, S13, S14, S15, S17, S18, S19, S20, S21, X01, 
            X02, X03, X04, X05

4.2. Calling the DLLs from Compaq Visual Fortran

To assist you, import library files (*.lib) have been provided. These remove the requirement to provide module definition files during the link process. (Please see the Compaq Visual Fortran Compiler Programmer's Guide for further details.)

Assuming that the directory containing the import libraries has been added to the LIB environment variable, you may compile and link to the NAG Fortran Library on the command line in the following manner:

df /c /Tf myprog.f
link myprog nag*.lib
where myprog.f is a Fortran source program calling NAG routines and nag*.lib is replaced with the names of the actual library files required (see the list of DLLs in Section 4.1).

If you are using Developer Studio, after establishing a workspace you should make the system aware of the import libraries by clicking on Project, then Settings, then Link and entering the full path to each required library (see the list of DLLs above) under Object/library modules. Remember to link to the import libraries not the DLL themselves.

If you wish to use Developer Studio to develop Fortran 90 programs using the NAG interface blocks you should also read Section 4.13.

4.3. Calling the DLLs from Salford FTN95

You will need SLINK version 1.26 or higher and FTN95 version 1.23 or higher.

(a) Compilation

No source file changes are necessary to call the DLLs from FTN95. However, since FTN95 uses a variant of the CDECL calling convention, the compiler has to be told that the routines in the DLLs are to be called using the Compaq Visual Fortran (CVF) calling convention. This can be accomplished using the /IMPORT_LIB command line switch as follows:
ftn95 myprog.f /import_lib nag*.lib
where myprog.f is a Fortran source program calling NAG routines and nag*.lib is replaced with the names of the actual library files required (see the list of DLLs in Section 4.1).

If required, the DLLs can be specified:

ftn95 myprog.f /import_lib nag*.dll
where nag*.dll is replaced with the names of the actual DLLs required.

The effect of this is to assume that all exported names in the .lib or .dll files are CVF STDCALL and that any call to them should use the CVF STDCALL calling convention.

External names passed via the argument list to a routine in a NAG DLL are automatically adjusted for whether or not they occur in the same source file as the call to the NAG routine.

(b) Linking

The NAG import libraries may be added to the SLINK command line as usual, e.g.
slink myprog.obj nag*.lib
Note that SLINK will follow the path specified in the LIB environment variable when searching for .lib files. It is not, therefore, necessary to place the path to the .lib files on the SLINK command line. Ensure that the LIB environment variable contains the path to them.

4.4. Calling the DLLs from Microsoft C

With care, the NAG Fortran Library may be used from within a C or C++ environment. To assist you to make the mapping between Fortran and C types, a set of C header files (headers\nagmk19.h) and a set of C++ header files (headers\nagmk19.hxx) are provided. It is recommended that if you wish to use a Fortran DLL routine, either cut and paste the relevant section of the appropriate file into your C or C++ application or simply include the relevant header file with your application. Detailed advice on the use of the DLLs from C and C++ is given in the Windows Help file C++headers.hlp.

The key information is as follows:

4.5. Calling the DLLs from Borland C++

Some selected tests have been made calling the DLLs from Borland C++, Version 5.0, which indicate that the DLLs may be used in conjunction with the Borland C++ compiler. The discussion in Section 4.4 applies equally to Borland.

Borland import libraries are not supplied but may easily be constructed from the DLLs as follows:

impdef name.def name.dll
implib name.lib name.def
where name denotes the name of the NAG DLL, for example, NAGAC. The first statement constructs a module definitions file, name.def, and the second takes this module definition file and constructs an import library, name.lib. Do not be alarmed by warning messages from impdef. These arise from the number of alternative symbols exported from the DLL in order to provide convenient forms for different users.

4.6. Calling the DLLs from Microsoft Visual Basic for Applications (Excel)

The Fortran DLLs are ideally suited for use within an Excel spreadsheet.

Detailed advice on the use of the DLLs from within Excel is given in the Windows Help file VBheaders.hlp.

The key information is as follows:

4.7. Calling the DLLs from Microsoft Visual Basic

Visual Basic and VBA have many similarities, so much of the VBA-specific information above applies directly to Visual Basic. Note especially the remarks about array conventions and string handling.

Detailed advice on the use of the DLLs from Visual Basic is given in the Windows Help file VBheaders.hlp.

The key information is as for VBA above.

4.8. Calling the DLLs from Delphi

The Fortran DLLs may be called from Delphi programs.

Detailed advice on the use of the DLLs from Delphi is given in the Windows Help file Delphi.hlp.

The key informationis as follows:

4.9. Calling the DLLs from PowerBuilder

It is believed that many of the routines from the DLLs may be called from PowerBuilder, although this has not been tested by NAG.

Detailed advice on the use of the DLLs from PowerBuilder is given in the Windows Help file PowerBuilder.hlp.

The key information is as follows:

4.10. Interpretation of Bold Italicised Terms

For this double precision implementation, the bold italicised terms used in the on-line documentation should be interpreted as:
real                 - DOUBLE PRECISION
basic precision      - double precision
complex              - COMPLEX*16
additional precision - quadruple precision (REAL*16)
machine precision    - the machine precision, see the value
                       returned by X02AJF in Section 4                          

Thus a parameter described as real should be declared as DOUBLE PRECISION in your program. If a routine accumulates an inner product in additional precision, it is using software to simulate quadruple precision.

Additional bold italicised terms are used in the example programs in the on-line documentation and they must be interpreted as follows:

real as an intrinsic function name - DBLE
imag                               - DIMAG
cmplx                              - DCMPLX
conjg                              - DCONJG
e in constants, e.g. 1.0e-4        - D, e.g. 1.0D-4
e in formats, e.g. e12.4           - D, e.g. D12.4

All references to routines in Chapter F07 - Linear Equations (LAPACK) and Chapter F08 - Least-squares and Eigenvalue Problems (LAPACK) use the LAPACK name, not the NAG F07/F08 name. The LAPACK name is precision dependent, and hence the name appears in a bold italicised typeface.

The examples in the on-line documentation use the single precision form of the LAPACK name. To convert this name to its double precision form, change the first character either from S to D or C to Z as appropriate.
For example:

sgetrf refers to the LAPACK routine name - DGETRF
cpotrs                                   - ZPOTRS

4.11. Explicit Output from NAG Routines

Certain routines produce explicit error messages and advisory messages via output units which either have default values or can be reset by using X04AAF for error messages and X04ABF for advisory messages. (The default values are given in Section 5.3). The maximum record lengths of error messages and advisory messages (including carriage control characters) are 80 characters, except where otherwise specified.

Care should be taken to ensure that X04AAF and X04ABF are taken from the DLL containing the routine producing the output. Satisfying the linker by including the NAGSX DLL will not, in general, suffice.

4.12. User Documentation

The following machine-readable information files are provided in the doc directory:

See Section 6 for additional documentation available from NAG.

4.13. Interface Blocks

The NAG Fortran Library Interface Blocks define the type and arguments of each user callable NAG Fortran Library routine, using Fortran 90 constructs. Although they are not essential to calling the NAG Fortran Library from Fortran 90 programs, they will allow a Fortran 90 compiler (such as the Compaq Visual Fortran compiler) to check that NAG Fortran Library routines are called correctly. The interface blocks enable the compiler to check that:

(a) Subroutines are called as such
(b) Functions are declared with the right type
(c) The correct number of arguments are passed
(d) All arguments match in type and structure

The interface blocks were generated automatically by analysing the source code for the NAG Fortran Library. As a consequence, and because they have been thoroughly tested, they are generally more reliable than individually written declarations.

The NAG Fortran Library Interface Block files are organised by Library chapter. The module names are:

nag_f77_a_chapter
nag_f77_c_chapter
nag_f77_d_chapter
nag_f77_e_chapter
nag_f77_f_chapter
nag_f77_g_chapter
nag_f77_h_chapter
nag_f77_m_chapter
nag_f77_p_chapter
nag_f77_s_chapter
nag_f77_x_chapter
These are supplied in pre-compiled form (.mod files). If you are compiling on the command line, to make one or more files accessible you should either copy them to the current directory or ensure that the directory containing the .mod files has been added to the INCLUDE environment variable.

If you are using Developer Studio, after establishing a workspace you should make the system aware of any interface blocks by clicking on Project, then Settings, then Fortran, choosing Preprocessor in the Category menu and entering the full paths to the interface blocks in the box labelled INCLUDE and USE Paths.

In order to make use of these modules from existing Fortran 77 code the following changes need to be made:

These changes are illustrated by showing the conversion of the Fortran 77 version of the example program for NAG Fortran Library routine S18DEF. Please note that this is not exactly the same as the example program that is distributed with this implementation. Each change is surrounded by comments boxed with asterisks.

*     S18DEF Example Program Text
*     Mark 14 Revised.  NAG Copyright 1989.
*******************************************************************
* Add USE statement for relevant chapters                         *
      USE NAG_F77_S_CHAPTER
*                                                                 *
*******************************************************************
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          N
      PARAMETER        (N=2)
*     .. Local Scalars ..
      COMPLEX*16       Z
      DOUBLE PRECISION FNU
      INTEGER          IFAIL, NZ
      CHARACTER*1      SCALE
*     .. Local Arrays ..
      COMPLEX*16       CY(N)
*     .. External Subroutines ..
*******************************************************************
* EXTERNAL declarations need to be removed (and type declarations *
*  for functions).                                                *
C      EXTERNAL         S18DEF
*                                                                 *
*******************************************************************
*     .. Executable Statements ..
      WRITE (NOUT,*) 'S18DEF Example Program Results'
*     Skip heading in data file
      READ (NIN,*)
      WRITE (NOUT,*)
      WRITE (NOUT,99999) 'Calling with N =', N
      WRITE (NOUT,*)
      WRITE (NOUT,*)
     +'   FNU            Z        SCALE       CY(1)              CY(2)
     +   NZ IFAIL'
      WRITE (NOUT,*)
   20 READ (NIN,*,END=40) FNU, Z, SCALE
      IFAIL = 0
*
      CALL S18DEF(FNU,Z,N,SCALE,CY,NZ,IFAIL)
*
      WRITE (NOUT,99998) FNU, Z, SCALE, CY(1), CY(2), NZ, IFAIL
      GO TO 20
   40 STOP
*
99999 FORMAT (1X,A,I2)
99998 FORMAT (1X,F7.4,'  (',F7.3,',',F7.3,')   ',A,
     +       2('  (',F7.3,',',F7.3,')'),I4,I4)
      END

5. Routine-specific Information

5.1. Option Setting

The routines listed below are designed to read optional parameter values from an external file. Although the NAG example programs in the on-line documentation show these values appended to the normal data file, in the DLL implementation this mechanism is not available. The user must place the options data in a separate file of a given name (see the table below). This is because two copies of the input/output system are effectively in use, one from the main program and the other from the DLL.
Routine Name	Options File Name

E04DJF	 	E04DJF.OPT
E04MGF	 	E04MGF.OPT
E04NDF	 	E04NDF.OPT
E04NGF	 	E04NGF.OPT
E04NLF	 	E04NLF.OPT
E04UDF		E04UDF.OPT
E04UHF		E04UHF.OPT
E04UQF		E04UQF.OPT

5.2. Connecting Files to Fortran Channel Numbers

Several NAG routines, contain the option to re-direct error and advisory messages to a different Fortran channel number using the NAG routines X04AAF and X04ABF. When the DLLs are called in a mixed-language environment this feature cannot be used, since there is no obvious way to connect a file to a Fortran channel number. In any case, X04AAF or X04ABF can be used only if they are exported from the same DLL as the routine in question, since they must share common block information with that routine and this is possible only within the same DLL. At Mark 19 X04AAF and X04ABF are exported from the DLLs NAGAC, NAGE04 and NAGSX only.

To partially address these issues the routines X04ACF and X04ADF, whose function is to open and close files, are exported from all the DLLs. These routines are described in the on-line documentation.

5.3. Further Information

Any further information which applies to one or more routines in this implementation is listed below, chapter by chapter.

(a) F06

In this implementation calls to the Basic Linear Algebra Subprograms (BLAS) are implemented by calls to the Intel MKL Library.

(b) G02

The value of ACC, the machine-dependent constant mentioned in several documents in the chapter, is 1.0D-13.

(c) P01

In general, hard failure, caused by an input value of IFAIL = 0, should be avoided by setting the IFAIL value to 1 before entry, contrary to the general advice in the on-line documentation. This is because Visual Basic, VBA, Delphi and similar packages will simply close down on encountering a STOP.

Similarly, setting IFAIL to -1 before calling a NAG routine is not recommended, because output to the standard output channel will again cause the Visual Basic, VBA and Delphi packages to close (Section 5.2 explains how to avoid this effect).

(d) S07 - S21

The constants referred to in the NAG Fortran Library Manual have the following values in this implementation:
S07AAF  F(1)   = 1.0D+13
        F(2)   = 1.0D-14
 
S10AAF  E(1)   = 18.50
S10ABF  E(1)   = 708.0
S10ACF  E(1)   = 708.0
 
S13AAF  x(hi)  = 708.3
S13ACF  x(hi)  = 1.0D+16
S13ADF  x(hi)  = 1.0D+17
 
S14AAF  IFAIL  = 1 if X > 170.0
        IFAIL  = 2 if X < -170.0
        IFAIL  = 3 if abs(X) < 2.23D-308
S14ABF  IFAIL  = 2 if X > 2.55D+305
 
S15ADF  x(hi)  = 26.6
        x(low) = -6.25
S15AEF  x(hi)  = 6.25
 
S17ACF  IFAIL  = 1 if X > 1.0D+16
S17ADF  IFAIL  = 1 if X > 1.0D+16
        IFAIL  = 3 if 0.0 < X <= 2.23D-308
S17AEF  IFAIL  = 1 if abs(X) > 1.0D+16
S17AFF  IFAIL  = 1 if abs(X) > 1.0D+16
S17AGF  IFAIL  = 1 if X > 103.8
        IFAIL  = 2 if X < -5.6D+10
S17AHF  IFAIL  = 1 if X > 104.1
        IFAIL  = 2 if X < -5.6D+10
S17AJF  IFAIL  = 1 if X > 104.1
        IFAIL  = 2 if X < -1.8D+9
S17AKF  IFAIL  = 1 if X > 104.1
        IFAIL  = 2 if X < -1.8D+9
S17DCF  IFAIL  = 2 if abs (Z) < 3.93D-305
        IFAIL  = 4 if abs (Z) or FNU+N-1 > 3.27D+4
        IFAIL  = 5 if abs (Z) or FNU+N-1 > 1.07D+9
S17DEF  IFAIL  = 2 if imag (Z) > 700.0
        IFAIL  = 3 if abs (Z) or FNU+N-1 > 3.27D+4
        IFAIL  = 4 if abs (Z) or FNU+N-1 > 1.07D+9
S17DGF  IFAIL  = 3 if abs (Z) > 1.02D+3
        IFAIL  = 4 if abs (Z) > 1.04D+6
S17DHF  IFAIL  = 3 if abs (Z) > 1.02D+3
        IFAIL  = 4 if abs (Z) > 1.04D+6
S17DLF  IFAIL  = 2 if abs (Z) < 3.93D-305
        IFAIL  = 4 if abs (Z) or FNU+N-1 > 3.27D+4
        IFAIL  = 5 if abs (Z) or FNU+N-1 > 1.07D+9
 
S18ADF  IFAIL  = 2 if 0.0 < X <= 2.23D-308
S18AEF  IFAIL  = 1 if abs(X) > 711.6
S18AFF  IFAIL  = 1 if abs(X) > 711.6
S18CDF  IFAIL  = 2 if 0.0 < X <= 2.23D-308
S18DCF  IFAIL  = 2 if abs (Z) < 3.93D-305
        IFAIL  = 4 if abs (Z) or FNU+N-1 > 3.27D+4
        IFAIL  = 5 if abs (Z) or FNU+N-1 > 1.07D+9
S18DEF  IFAIL  = 2 if real (Z) > 700.0
        IFAIL  = 3 if abs (Z) or FNU+N-1 > 3.27D+4
        IFAIL  = 4 if abs (Z) or FNU+N-1 > 1.07D+9
 
S19AAF  IFAIL  = 1 if abs(x) >= 49.50
S19ABF  IFAIL  = 1 if abs(x) >= 49.50
S19ACF  IFAIL  = 1 if X > 997.26
S19ADF  IFAIL  = 1 if X > 997.26
 
S21BCF  IFAIL  = 3 if an argument < 1.579D-205
        IFAIL  = 4 if an argument >= 3.774D+202
S21BDF  IFAIL  = 3 if an argument < 2.820D-103
        IFAIL  = 4 if an argument >= 1.404D+102

(e) X01

The values of the mathematical constants are:
X01AAF (PI)    = 3.1415926535897932
X01ABF (GAMMA) = 0.5772156649015329

(f) X02

The values of the machine constants are:

The basic parameters of the model

 
X02BHF = 2
X02BJF = 53
X02BKF = -1021
X02BLF = 1024
X02DJF = .TRUE.
Derived parameters of the floating-point arithmetic
X02AJF = 1.11022302462516D-16
X02AKF = 2.22507385850721D-308
X02ALF = 1.79769313486231D+308
X02AMF = 2.22507385850721D-308
X02ANF = 2.22507385850721D-308
Parameters of other aspects of the computing environment
X02AHF = 1.84467440737095D+19
X02BBF = 2147483647
X02BEF = 15
X02DAF = .FALSE.

(g) X04

The default output units for error and advisory messages for those routines which can produce explicit output are both Fortran unit 6.

6. Documentation

A printed copy of the NAG Fortran Library Introductory Guide is normally provided with this implementation.

A full on-line version of the NAG Fortran Library Manual is provided in the form of Portable Document Format (PDF) files, and is included with this implementation on the distribution medium.

Abbreviated on-line documentation of the routines is also provided in Windows Help file form as part of this implementation.

Printed copies of the NAG Fortran Library Manual are available for purchase; please refer to the NAG documentation order form (available on the NAG websites, see Section 6 (c)) for details of current prices.

7. Support from NAG

(a) Contact with NAG

Queries concerning this document or the implementation generally should be directed initially to your local Advisory Service. If you have difficulty in making contact locally, you can contact NAG directly at one of the addresses given in the Appendix. Users subscribing to the support service are encouraged to contact one of the NAG Response Centres (see below).

(b) NAG Response Centres

The NAG Response Centres are available for general enquiries from all users and also for technical queries from sites with an annually licensed product or support service.

The Response Centres are open during office hours, but contact is possible by fax, email and phone (answering machine) at all times.

When contacting a Response Centre please quote your NAG site reference and NAG product code (in this case FLDLL194Z).

(c) NAG Websites

The NAG websites are an information service providing items of interest to users and prospective users of NAG products and services. The information is reviewed and updated regularly and includes implementation availability, descriptions of products, downloadable software, product documentation and technical reports. The NAG websites can be accessed at

http://www.nag.co.uk/

or

http://www.nag.com/ (in North America)

or

http://www.nag-j.co.jp/ (in Japan)

(d) NAG Electronic Newsletter

If you would like to be kept up to date with news from NAG you may want to register to receive our electronic newsletter, which will alert you to special offers, announcements about new products or product/service enhancements, case studies and NAG's event diary. To register visit the NAG Ltd website or contact us at nagnews@nag.co.uk.

8. User Feedback

Many factors influence the way NAG's products and services evolve and your ideas are invaluable in helping us to ensure that we meet your needs. If you would like to contribute to this process we would be delighted to receive your comments. We have provided a short survey on our website at www.nag.co.uk/local/feedback to enable you to provide this feedback. Alternatively feel free to contact the appropriate NAG Response Centre who will be happy either to record your comments or to send you a printed copy of the survey.

Appendix - Contact Addresses

NAG Ltd
Wilkinson House
Jordan Hill Road
OXFORD  OX2 8DR                         NAG Ltd Response Centre
United Kingdom                          email: support@nag.co.uk
 
Tel: +44 (0)1865 511245                 Tel: +44 (0)1865 311744
Fax: +44 (0)1865 310139                 Fax: +44 (0)1865 310139
 
Nihon NAG KK
Yaesu Nagaoka Building No. 6 
1-9-8 Minato
Chuo-ku
Tokyo
Japan
email: help@nag-j.co.jp

Tel: +81 (0)3 5542 6311
Fax: +81 (0)3 5542 6312

[NP3514/UN]