Using Fortran 77 and NAG's Fortran Library

The document NAG Fortran Library contains an overview of NAG and information on its use that should be read prior to reading this document. The discussion below assumes that you have configured your UNIX account as described in that document.

In this example we have a simple Fortran77 program in the file gammaTest.f (you can see the listing of this file below). It is a modified version of the example program from NAG to test the Gamma Function evaluation program s14aaf. With this file in the current directory this example consists of the following the steps.

nagshell
Start a shell setup for NAG (requires dot file configuration)
make gammaTest
compiles the gammaTest.f file and makes an executable file called "gammaTest"
gammaTest
Run the Gamma Function test.
exit
Exit the nag shell and return the starting evironment.

The output from a sample terminal session is shown below, followed by a discussion of the steps.

The nagshell alias and environment variables used below are available if you have made the suggested UNIX configuration changes described elsewhere.

<100>% nagshell
<1>% make gammaTest
f77 -o gammaTest gammaTest.f -L/opt/lib/nagfl16df -lnag
gammaTest.f:
MAIN:
<2>% gammaTest
5.000D+00 2.400D+01 0
<3>% exit
exit
<101>%

Listing of the gammaTest.f sample program

*     S14AAF Example Program Text
* Mark 14 Revised. NAG Copyright 1989.
* .. Parameters ..
INTEGER NIN, NOUT
PARAMETER (NIN=5,NOUT=6)
* .. Local Scalars ..
DOUBLE PRECISION X, Y
INTEGER IFAIL
* .. External Functions ..
DOUBLE PRECISION S14AAF
EXTERNAL S14AAF
* .. Executable Statements ..
X = 5.0
IFAIL = 1
*
Y = S14AAF(X,IFAIL)
*
WRITE (NOUT,99999) X, Y, IFAIL
STOP
*
99999 FORMAT (1X,1P,2D12.3,I7)
END

[Back to NAG home page]

Last modified: March 3, 2005
This page maintained by Dean Nairn
Copyright © University of Delaware, 2000.