!----------------------------------------------------------------------
!     Copyright (c) 2001 Shin-ichi Takehiro. All rights reserved.
!----------------------------------------------------------------------

program sntest_multi

  use snpack

  implicit none

  integer,parameter  :: im=32, jm=16    ! 格子点の設定(X,Y)
  integer,parameter  :: km=5, kdim=2
  integer,parameter  :: nm=10
  double precision,parameter :: radius=1.0
  double precision,parameter :: pi=3.14159265358979

  double precision, dimension(im,jm,kdim)         :: gg  ! 格子点
  double precision, dimension(im,jm,1)          :: gg1  ! 格子点
  double precision, dimension((nm+1)*(nm+1),kdim) :: ep  ! スペクトル
  double precision, dimension((nm+1)*(nm+1),1)  :: ep1 ! スペクトル

  integer :: i, j, n, m

  call sninitial(nm,im,jm,km)

  do i=1,im
     write(6,*) i,longitude(i), lon_weight(i)
  enddo
  do j=1,jm
     write(6,*) j,latitude(j), lat_weight(j)
  enddo

  ep=0

  n=1 ; m=-1
  write(6,*) 'n,m?'
  read(5,*) n,m
  ep(l_nm(n,m),1)=1.0

  n=1 ; m=-1
  write(6,*) 'n,m?'
  read(5,*) n,m
  ep(l_nm(n,m),2)=1.0

  n=1 ; m=-1
  write(6,*) 'n,m?'
  read(5,*) n,m
  ep1(l_nm(n,m),1)=1.0

  gg = gg_ep(ep)
  gg1 = gg_ep(ep1)

  call gropn(1)
  call grfrm
  call grsvpt(0.2,0.8,0.2,0.8)
  call grswnd(0.0,360.0,-90.0,90.0)
  call grstrn(1)

  !call sgssim( 1.0, 0.0, 0.0 )
  !call sgsmpl( 0.0, 0.0, 0.0 )
  !call grstrn(30)

  call grstrf
  call usdaxs
  call udcntr(real(gg(:,:,1)),im,im,jm)

  call grfrm
  call grsvpt(0.2,0.8,0.2,0.8)
  call grswnd(0.0,360.0,-90.0,90.0)
  call grstrn(1)
  call usdaxs
  call udcntr(real(gg(:,:,2)),im,im,jm)

  call grfrm
  call grsvpt(0.2,0.8,0.2,0.8)
  call grswnd(0.0,360.0,-90.0,90.0)
  call grstrn(1)
  call usdaxs
  call udcntr(real(gg1),im,im,jm)

  call grcls

end program sntest_multi

