!=======================================
! 2D cumulus model - kaminari
!  - subroutine init_value
! 
! Author    : TAKAHASHI Koko
! Date      : 2003/12/04  $B:G=*99?7(B
!             2003/11/11  $B?75,:n@.(B
! Note      : $B=i4|CM@_Dj(B
!
!=======================================
!--- 1$B9TL\F~NOJQ?t(B, 2,3$B9TL\=PNOJQ?t(B
subroutine init_value(im,km,dz,cp,rd,prss_sfc,pi_bs, &
     &                u,w,prss,pi,pi_all,temp,ptemp,vptemp)
 
  implicit none

  integer(8), intent(in) :: im, km

  real(8), intent(in) :: dz
  real(8), intent(in) :: cp, rd, prss_sfc

  real(8), intent(in) :: pi_bs(-2:im,-2:km)

  real(8), intent(out) :: u(-2:im,-2:km+1)
  real(8), intent(out) :: w(-2:im+1,-2:km)

  real(8), intent(out) :: prss(-2:im,-2:km)
  real(8), intent(out) :: pi(-2:im,-2:km)
  real(8), intent(out) :: pi_all(-2:im,-2:km)
  real(8), intent(out) :: temp(-2:im,-2:km)
  real(8), intent(out) :: ptemp(-2:im,-2:km)
  real(8), intent(out) :: vptemp(-2:im,-2:km)
!  real(8), intent(out) :: qv(-2:im,-2:km)
!  real(8), intent(out) :: qc(-2:im,-2:km)
!  real(8), intent(out) :: qr(-2:im,-2:km)
!  real(8), intent(out) :: km_sub(-2:im,-2:km)

  integer(8)             :: i, k

  real(8)             :: qv(-2:im,-2:km)

!  real(8)             :: x(0:im,0:km)
  real(8)             :: z(0:im,0:km)

  !---------------
  !--- $B?eJ?B.EY(B u
  do k = 0,km-1
     do i = 0,im-3
        u(i,k) = 0.0d0
     end do
  end do

  !---------------
  !--- $B1tD>B.EY(B w
  do k = 0,km-2
     do i = 0,im-2
        w(i,k) = 0.0d0
     end do
  end do

  do k = 0,km-2
     do i = 0,im-3
!        x(i,k) = dx*i
        z(i,k) = dz*k
     end do
  end do

  do k = 0,km-2
     do i = 0,im-2
        !---------------
        !--- $B05NO(B
       prss(i,k) = prss_sfc                                &
             &      + 5.0d3*exp(-(z(i,k)-1.0d4/2.0d0)**2.0d0/(5.0d3))!&
!             &          -(z(i,k)-9.0d3/2.0d0)**2.0d0/(2.0d3))
!        prss(i,k) = prss_sfc

        !--- $BL5<!8505NO(B ($B05NO(B prss -> $BL5<!8505NO(B pi $B=PNO(B)
        call prss2pi(0,i,k,im,km,prss_sfc,rd,cp,prss,pi_all)
        pi(i,k) = pi_all(i,k) - pi_bs(i,k)

        !---------------
        !--- $B29EY(B
        temp(i,k) = 0.0d0
        !  temp(i,k) = 1.0d2*exp(-(x(i,k) - 1.0d4/2.0d0)**2.0d0/(5.0d2**2.0d0))

        !--- $B290L(B
        ptemp(i,k) = temp(i,k)/pi(i,k)

        !---------------
        !--- $B?e>x5$$N:.9gHf(B
        qv(i,k) = 0.0d0

        !--- $B2>290L(B
        vptemp(i,k) = ptemp(i,k)*(1.0d0 + 6.1d-2*qv(i,k))

        !---------------
        !--- $B1@?e$N:.9gHf(B
        !  qc(i,k) = 0.00d0

        !---------------
        !--- $B1+?e$N:.9gHf(B
        !  qr(i,k) = 0.00d0

        !---------------
        !--- $B12:.9g78?t(B
        !  km_sub(i,k) = 0.0d0
     end do
  end do

end subroutine init_value

