!=======================================
! 2D cumulus model - kaminari
!  - subroutine jacobian (2D)
! 
! Author    : TAKAHASHI Koko
! Date      : 2003/11/21 $B:G=*99?7(B
!             2003/11/01 $B?75,:n@.(B
! 
!=======================================s
!--- 1 $B9TL\(B  : $BF~NOJQ?t(B
!--- 2,3 $B9TL\(B: $B=PNOJQ?t(B
subroutine jacobian(im,km,                              &
     &              g_sqrt,g_sqrt_x,g_sqrt_z,g_sqrt_xz,g13, &
     &              g13x,g13z,g13xz)

  implicit none

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

  real(8), intent(out) :: g_sqrt(-2:im+1,-2:km+1)    ! $B%d%3%S%"%s$N(B1/2$B>h(B
  real(8), intent(out) :: g_sqrt_x(-2:im+1,-2:km+1)
  real(8), intent(out) :: g_sqrt_z(-2:im+1,-2:km+1)
  real(8), intent(out) :: g_sqrt_xz(-2:im+1,-2:km+1)
  real(8), intent(out) :: g13(-2:im+1,-2:km+1)    ! $B%d%3%S%"%s$N(B13$B@.J,(B
  real(8), intent(out) :: g13x(-2:im+1,-2:km+1)
  real(8), intent(out) :: g13z(-2:im+1,-2:km+1)
  real(8), intent(out) :: g13xz(-2:im+1,-2:km+1)

!  real(8), intent(in) :: zs(-2:im+1)
!  real(8), intent(in) :: dx
!  real(8), intent(in) :: h

!  real(8), intent(in) :: z(-2:im+1,-2:km+1)

  integer(8)          :: i, k

  do k = 0, km-1
     do i = 0, im-1
        g_sqrt(i,k) = 1.0d0
        g13(i,k) = 0.0d0

        !  g_sqrt(i,k) =  (h - zs(i))/h

        !  g13(i,k) = (z(i,k) - h)/(h - zs(i))   &
        !       &     *(zs(i) - zs(i-1))/dx

        !--- g_sqrt$B$N(Bx$BJ?6QA`:n(B: u(i,k) $B$HF1$80LCV(B
        g_sqrt_x(i,k) = (g_sqrt(i,k) + g_sqrt(i-1,k))/2.0d0

        !--- g_sqrt$B$N(Bz$BJ?6QA`:n(B: w(i,k) $B$HF1$80LCV(B
        g_sqrt_z(i,k) = (g_sqrt(i,k) + g_sqrt(i,k-1))/2.0d0

        !--- g_sqrt$B$N(Bxz$BJ?6QA`:n(B: g13(i,k) $B$HF1$80LCV(B
        g_sqrt_xz(i,k) = (                                        &
             &            g_sqrt(i,k) + g_sqrt(i-1,k)             &
             &            + g_sqrt(i,k-1) + g_sqrt(i-1,k-1)       &
             &            )/4.0d0

        !--- g13$B$N(Bx$BJ?6QA`:n(B: w(i,k) $B$HF1$80LCV(B
        g13x(i,k) = (g13(i,k) + g13(i-1,k))/2.0d0

        !--- g13$B$N(Bz$BJ?6QA`:n(B: u(i,k) $B$HF1$80LCV(B
        g13z(i,k) = (g13(i,k) + g13(i,k-1))/2.0d0

        !--- g13$B$N(Bxz$BJ?6QA`:n(B: $B%9%+%i!<NL(B(i,k)$B$HF1$80LCV(B
        g13xz(i,k) = (                               &
             &        g13(i+1,k+1) + g13(i+1,k)      &
             &        + g13(i,k+1) + g13(i,k)        &
             &       )/4.0d0

     end do
  end do

  g_sqrt(:,:) = 1.0d0
  g_sqrt_x(:,:) = 1.0d0
  g_sqrt_z(:,:) = 1.0d0
  g_sqrt_xz(:,:) = 1.0d0

end subroutine jacobian

