program test_spline implicit none interface subroutine spline(t,y,x,v) implicit none double precision, intent(in), dimension(:) :: t,y,x double precision, intent(out), dimension(:) :: v end subroutine spline end interface integer, parameter :: ndata=5 integer, parameter :: nplot=201 double precision, dimension(ndata) :: t = (/-1.d0,-.5d0,0.d0,0.5d0,1.0d0/) double precision, dimension(ndata) :: y = (/0.d0,2.d0,0.d0,-4.d0,1.d0/) double precision, dimension(nplot) :: x=(/ (-1.d0+(i-1)*1.0D-2, i=1,nplot) /) double precision, dimension(nplot) :: v integer :: i ! call spline(t,y,x,v) ! open(10, file='Data.m',action='WRITE') open(20, file='Results.m',action='WRITE') ! do i=1,ndata write(10,FMT='(F24.16,4X,F24.16)') t(i), y(i) end do ! do i=1,nplot write(20,FMT='(F24.16,4X,F24.16)') x(i), v(i) end do ! close(10) close(20) ! end program test_spline
Results of this example are shown in the next Figure.