test_inter1d.f90
604 Bytes
program inter1d
use fvn_interpol
implicit none
integer(kind=4),parameter :: ndata=33
integer(kind=4) :: i,nout
real(kind=8) :: f,fdata(ndata),h,pi,q,sin,x,xdata(ndata)
real(kind=8) ::tv
intrinsic sin
f(x)=sin(x)
xdata(1)=0.
fdata(1)=f(xdata(1))
h=1./32.
do i=2,ndata
xdata(i)=xdata(i-1)+h
fdata(i)=f(xdata(i))
end do
call init_random_seed()
call random_number(x)
q=fvn_quad_interpol(x,ndata,xdata,fdata)
tv=f(x)
write(*,'("x y z ",1(f8.5))') x
write(*,'("Calculated (real) value :",f8.5)') tv
write(*,'("fvn interpolation : ",f8.5)') q
write(*,'("Relative fvn error :",e12.5)') abs((q-tv)/tv)
end program