Blame view

fvn_test/test_inter3d.f90 957 Bytes
27d3b84d6   daniau   git-svn-id: https...
1
  program test_inter3d
2919a9e2d   daniau   git-svn-id: https...
2
  use fvn_interpol
27d3b84d6   daniau   git-svn-id: https...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  implicit none
  integer(kind=4),parameter :: nx=21,ny=42,nz=18
  integer(kind=4) :: i,j,k
  real(kind=8) :: f,fdata(nx,ny,nz),dble,pi,q,sin,x,xdata(nx),y,ydata(ny),z,zdata(nz)
  real(kind=8) :: tv
  intrinsic dble,sin
  f(x,y,z)=sin(x+2.*y+3.*z)
  do i=1,nx
        xdata(i)=2.*(dble(i-1)/dble(nx-1))
  end do
  do i=1,ny
        ydata(i)=2.*(dble(i-1)/dble(ny-1))
  end do
  do i=1,nz
        zdata(i)=2.*(dble(i-1)/dble(nz-1))
  end do
  do i=1,nx
        do j=1,ny
              do k=1,nz
                    fdata(i,j,k)=f(xdata(i),ydata(j),zdata(k))
              end do
        end do
  end do
  call init_random_seed()
  call random_number(x)
  call random_number(y)
  call random_number(z)
  q=fvn_quad_3d_interpol(x,y,z,nx,xdata,ny,ydata,nz,zdata,fdata)
  tv=f(x,y,z)
  write(*,'("x y z ",3(f8.5))') x,y,z
  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