!----------------------------------------------------------------------
!     Copyright (c) 2024 Shin-ichi Takehiro. All rights reserved.
!----------------------------------------------------------------------
!
!表題  wa_zonal_module_interpolate テストプログラム :: 補間関数のテスト
!
!履歴  2024/02/17  竹広真一 wa_wave_module_interpolate_test.f90 より改造
!
program wa_zonal_module_interpolate_test

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

  integer, parameter :: im=1, jm=16, nm=10, km=2

  real(8), allocatable, dimension(:,:) ::  wa_data
  real(8), dimension(0:im-1,1:jm,km)   ::  xya_data

  ! 判定誤差設定
  integer, parameter :: check_digits = 10
  integer, parameter :: ignore = -11

  real(8) :: Alon
  real(8) :: Alat
  real(8), dimension(km) :: a_data_sol
  real(8) :: pi

  pi = atan(1.0D0)*4.0D0
  Alon = pi/5 ; Alat = pi/3

  call MessageNotify('M','wa_zonal_module_interpolate_test', &
                         'wa_zonal_module_interpolate tests') 


  !---- Y_1^0 Y_2^0 のテスト ----
  call wa_Initial( nm, im, jm, km )
  allocate(wa_data(nm+1,km))

  xya_data(:,:,1) = sqrt(3.0D0)*sin(xy_Lat)              ! Y_1^0
  a_data_sol(1) = sqrt(3.0D0)*sin(ALat)

  xya_data(:,:,2)  = sqrt(5.0D0)*(3.0D0*sin(xy_Lat)**2-1.0D0)/2.0D0  ! P_2^0
  a_data_sol(2) = sqrt(5.0D0)*(3.0D0*sin(ALat)**2-1.0D0)/2.0D0

  wa_data = wa_xya(xya_data)
  call AssertEqual(&
    message='a_Interpolate_wa with Y_1^0, Y_2^0',                 &
    answer = a_Interpolate_wa(wa_data,alon,alat),                 &
    check =  a_data_sol,                                          &
    significant_digits = check_digits, ignore_digits = ignore     &
    )

  call MessageNotify('M','wa_zonal_module_interpolate_test', &
                      'wa_zonal_module_interpolate function tests succeeded') 

end program wa_zonal_module_interpolate_test

