Using Fortran 90 and CTT's Fortran 90 MP Modules

The document IMSL Computational Technology Toolkit contains an overview of CTT 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.

This document discusses a VNI Inc. sample program that uses two Fortran 90 MP modules - one to generate a random test matrix and one to calculate its singular value decomposition (SVD). The program also checks the results by using Fortran 90 matrix intrinsic functions. These functions replace the need to call older IMSL basic matrix algebra operations such as matrix multiplication. This session was run using the Sun Studio 11 compilers and SMP Fortran 90 load libraries. 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>% mkdir testctt
<2>% cd testctt
<3>% cp $CTT_EXAMPLES/f90/manual/lin_svd_ex1.f90 .
<4>% make lin_svd_ex1
f90 -openmp=noopt -ftrap=%none -xtarget=generic -M/opt/vni/CTT6.1/include/solaris
-o lin_svd_ex1 lin_svd_ex1.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
<5>% ./lin_svd_ex1
Example 1 for LIN_SVD is correct.
<6>% exit
<101>%

Listing of the lin_svd_ex1.f90 sample program

      use lin_svd_int
use rand_gen_int

implicit none

! This is Example 1 for LIN_SVD.

integer, parameter :: n=32
real(kind(1d0)), parameter :: one=1d0
real(kind(1d0)) err
real(kind(1d0)), dimension(n,n) :: A, U, V, S(n), y(n*n)

! Generate a random n by n matrix.
call rand_gen(y)
A = reshape(y,(/n,n/))

! Compute the singular value decomposition.
call lin_svd(A, S, U, V)

! Check for small residuals of the expression A*V - U*S.
err = sum(abs(matmul(A,V) - U*spread(S,dim=1,ncopies=n))) &
/ sum(abs(S))
if (err <= sqrt(epsilon(one))) then
write (*,*) 'Example 1 for LIN_SVD is correct.'
end if

end

[Back to CTT home page]

Last modified: May 17, 2005
This page maintained by Dean Nairn
Copyright © University of Delaware, 2005.