!=====================================================================
! 2 $B<!85I9>2%b%G%k(B
!
! $BMzNr(B
!      2001/12/02 $B%b%8%e!<%k2=$r9T$&(B
!      2001/12/13 $BI=<($H7W;;(B($BG\@:EY(B)$B$rJ,N%(B
!=====================================================================

program main 
  use prm                                        ! $BDj?t%Q%i%a!<%?%b%8%e!<%k(B
  use u_pack                                     ! $BB.EY$K4X$9$k%b%8%e!<%k(B
  implicit none  


! $BJQ?t(B 
  real(8)                 :: h(0:im-1)           ! $BI98|(B($B@0?t3J;RE@(B)
  real(8)                 :: df(0:im-1)          ! $B%U%i%C%/%9(B($BH>@0?t(B)$B$N:9(B
  real(8)                 :: u(0:im-1, 0:km)     ! $B?eJ?B.EY(B u($B?eJ?(B, $BH>@0?t(B)
  real(8)                 :: w(0:im-1, 0:km)     ! $B1tD>B.EY(B w($B?eJ?(B, $BH>@0?t(B)
! real(8)                 :: T                   ! $B29EY(B

! $B:BI8JQ?t(B 
! real(8)                :: x(0:im-1)            ! x $B:BI8(B($B=PNO$N:]$KI,MW(B)
! real(8)                :: z(0:im-1,0:km)       ! z $B:BI8(B($B=PNO$N:]$KI,MW(B)

  real(8)                :: zk(0:km)             ! $B&F:BI8(B
  integer                :: it !, i, k              ! do $BJQ?t(B


! $B=i4|CM$N@_Dj(B
! $B=i4|I9>2$N@_Dj(B
  integer , parameter  :: x_s = 12               ! $B=i4|I9>2B&6-3&(B
  h(0:x_s) = hmax                                
  h(x_s+1:im-1) = 0.                       


! $B:BI8CM$N@_Dj(B
! x  = (/(i, i=0, im-1)/) * dx
  zk = (/0.0, 0.02, 0.05, 0.10, 0.17, 0.25,0.40, 0.55, 0.70, 0.85, 1.0/)


! $B7W;;7k2L%U%!%$%k%*!<%W%s(B
  open(7, file='h.txt')
  open(8, file='u.txt')
  open(9, file='w.txt')

! $B;~4V@QJ,(B
  do it = 1, nt
     call get_u(h, zk, u)                ! $B;~9o(B t $B$NB.EY(B u $B=PNO(B
     call get_w(h, zk, u, w)             ! $B;~9o(B t $B$NB.EY(B w $B=PNO(B
     call get_F(h, zk, u, df)            ! $B;~9o(B t $B$NB.EY(B u $B$NI98|@QJ,(B f
                                         ! df = f(i+1) - f(i)
!     call get_Ms(xi, Ms)                ! $B;~9o(B t $B$N@5L#$N<ANL=*;_J,I[(B

! Euler $BK!(B
     h    = h -  dt *(df/ dx)            ! t+1 $B%9%F%C%WL\$N(B h $B$N7W;;(B
  end do


! if(mod(it, ndisp) == 0)then
  write(7, '(e)' )real(h,4)
  write(8, '(e)' )real(u,4)
  write(9, '(e)' )real(w,4)
! end if

! $B%U%!%$%k%/%m!<%:(B
  close(7)
  close(8)
  close(9)

end program main
