!----------------------------------------------------------------------
!     Copyright (c) 2016 Shin-ichi Takehiro. All rights reserved.
!----------------------------------------------------------------------
!
!表題  w_plane_module テストプログラム :: 補間関数のテスト
!
!履歴  2016/01/01  竹広真一
!
program w_plane_module_Interpolate_test

  use dc_message, only : MessageNotify
  use dc_test, only : AssertEqual
  use w_plane_module
  implicit none

  integer, parameter :: im=128, jm=64, nm=42
  real(8), parameter :: Radius = 1.0D0

  real(8), parameter :: sigma = 5.0D-1
  integer :: m
  
  real(8), dimension(0:im-1,1:jm)   ::  ps_data
  real(8) :: pi

  real(8)  ::  xval = 2.0D-1
  real(8)  ::  yval = 3.5D-1
  real(8)  ::  sval
  real(8)  ::  pval
  real(8)  ::  answer
  
  ! 判定誤差設定
  integer, parameter :: check_digits = 10
  integer, parameter :: ignore = -11

  pi = atan(1.0D0)*4.0D0

  call MessageNotify('M','w_plane_module', &
                         'w_plane_module interpolate functions tests') 

  call w_plane_Initial( nm, im, jm, radius )

  do m=0,2
  
     ps_data = exp( -ps_S**2/sigma**2 ) * sin( m * ps_Phi ) * ps_S**m

     sval = sqrt(xval**2 + yval**2)
     pval = atan(yval/xval)
     answer = exp( -sval**2/sigma**2 ) * sin( m * pval ) * sval**m

     !---- 補間変換 ----
     call AssertEqual(&
          message='Test of InterpolateOnXY_w',                          &
          answer = answer,                                              &
          check = InterpolateOnXY_w(w_ps(ps_data),xval,yval),           &
          significant_digits = check_digits, ignore_digits = ignore     &
          )

  
  enddo
  
end program w_plane_module_Interpolate_test

