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 Fortran 77 program in the file gammaTest.f. You can see the listing of this file below. It is a modified version of  NAG's example program from NAG that tests the gamma function  s14aaf. With this file in the current directory this example consists of the following steps.

nagshell
Starts a shell setup for NAG
make gammaTest
Compiles the gammaTest.f file and makes an executable file called "gammaTest"
gammaTest
Runs the Gamma Function test.
exit
Exits the NAG shell and returns to the starting environment.

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

The nagshell alias and environmental variables used below will be available only if you made the UNIX configuration changes suggested elsewhere.

<100>% nagshell
<1>% make gammaTest
f77 -dalign -xtarget=ultra -mt -o gammaTest gammaTest.f \
-L/opt/nag/aslir6/flso619da -lnag-spl -xlic_lib=sunperf -lsocket -lnsl -lintl
gammaTest.f:
MAIN:
<2>% ./gammaTest
5.000D+00 2.400D+01 0
<3>% exit
exit
<101>%

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, 2005.