Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.mrao.cam.ac.uk/~rachael/compphys/examples/spline.f90
Дата изменения: Tue Sep 13 13:08:16 2005
Дата индексирования: Tue Oct 2 10:58:54 2012
Кодировка:

Поисковые слова: http www.stsci.edu science goods
program test_spline

implicit none

! define sizes of arrays
integer, parameter :: m = 20

! size of arrays used by NAG to store spline
integer, parameter :: lck = m + 4

! size of NAG work array
integer, parameter :: lwk = 6 * m + 16

! find the kind of a high precision variable, by finding kind(1.0d0)
integer, parameter :: dp = kind(1.0d0)

integer :: i, ifail

! NAG requires high precision variables
real(dp) :: x(m), y(m), &
lambda(lck), c(lck), work(lwk), &
xv, yv

! set up a model function
do i = 1, m
x(i) = (i - 1) * 0.1d0
y(i) = sin(x(i)) * cos(x(i))
end do

! fit spline using NAG routine: if ifail == 0 on entry, then NAG will
! print an error message and stop the program if an error occurs
ifail = 0
call E01BAF(m, x, y, lambda, c, lck, work, lwk, ifail)

! as a test print out a value of the interpolated function
! use NAG routine to evaluate the spline
xv = 0.31372d0
ifail = 0 ! strictly unnecessary here, but good practice...
call E02BBF(lck, lambda, c, xv, yv, ifail)

write(*,*) 'At xv = ', xv, ', interpolated value = ', &
yv, ', function = ', sin(xv) * cos(xv)

end program test_spline