When you are unable to find a suitable Fortran 90 CTT module, you will have to use the earlier IMSL Fortran 77 routines, now known as the Fortran Numerical Library (FNL).
The VNI-supplied Numerical_Libraries module provides some features only available with modules (such as parameter type-checking). Therefore, when programming in Fortran 90 with FNL routines, you should add a
use Numerical_Librariesstatement to your Fortran 90 program.
The following example calculates the product of gamma(a) and gamma(1-a) by two methods and compares their results. The first method uses the gamma function from the FNL library. The second method uses standard Fortran functions and the "Reflection Formula",
The output from a sample terminal session is shown below, followed by a discussion of the steps. This example is run using the the Sun Studio 11, and the f90 source file is in gammaTest.f90. The cttshell alias and environment variables used below are available if you have made the suggested UNIX configuration changes described elsewhere.
setenv commands in setup files | |
---|---|
CTT_DIR | /opt/vni/CTT6.1 |
LDLIBS | "$LINK_F90_SMP" |
<100>% cttshell
<1>% touch gammaTest.f90
<2>% make gammaTest
f90 -openmp=noopt -ftrap=%none -xtarget=generic
-M/opt/vni/CTT6.1/include/solaris -o gammaTest gammaTest.f90
-R/opt/vni/CTT6.1/lib/lib.solaris -L/opt/vni/CTT6.1/lib/lib.solaris
-Bdynamic -limsl -limslsmp -xlic_lib=sunperf -ldl -lnsl -lsocket
<3>% ./gammaTest
a= 1.255
gamma(a)= 0.9053857662433382
gamma(1-a)= -4.8318715357682604
gamma(a)*gamma(1-a)= -4.374707712800922
pi/sin(pi*a)= -4.374707712800924
<4>% exit
<101>%
program gammaTest
use Numerical_Libraries
implicit none
integer, parameter :: F=selected_real_kind(12,100)
real(kind=F) :: a = 1.255_F
real(kind=F) :: pi = 3.1415926535897932384626433832795_F
! Write some results. Use gamma or dgamma to go with kind=F
write(*,*) ' a=', a
write(*,*) ' gamma(a)=', dgamma(a)
write(*,*) ' gamma(1-a)=', dgamma(1-a)
! These last two results should be the same
write(*,*) 'gamma(a)*gamma(1-a)=', dgamma(a)*dgamma(1-a)
write(*,*) ' pi/sin(pi*a)=', pi/sin(pi*a)
end
Last modified: July 13, 2005
This page maintained by Dean Nairn
Copyright © University of Delaware, 2005.