!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2005. All rights reserved.
!---------------------------------------------------------------------
!
!= Module dcpam_ape_dynamics_mod
!
!   * Developers: Morikawa Yasuhiro, Yamada Yukiko
!   * Version: $Id: dcpam_ape_dynamics.f90,v 1.1 2005/11/29 14:47:21 yukiko Exp $
!   * Tag Name: $Name: dcpam3-20051207 $
!   * Change History: 
!
!== Overview
!
!DCPAM-APE Dynamics Main module
!
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!== Future Plans
!
!

module dcpam_ape_dynamics_mod

  !== Dependency
  use type_mod,      only : STRING

  implicit none

  !== Public Interface
  private
  public :: dcpam_ape_dynamics       ! subroutines

  character(STRING),parameter:: version = &
       & '$Id: dcpam_ape_dynamics.f90,v 1.1 2005/11/29 14:47:21 yukiko Exp $'
  character(STRING),parameter:: tagname = '$Name: dcpam3-20051207 $'

contains

  !== Dynamics main module
  !
  !=== Dynamics main module
  !
  !DCPAM-APE Dynamics Main module
  !
  subroutine dcpam_ape_dynamics( Dims, Vars_b, Vars_n, Vars_a )
  !==== Dependency
    use dycore_type_mod, only: DYCORE_VARS, DYCORE_DIMS, STRING, INTKIND, REKIND
    use dycore_dynamics_mod, only: dycore_dynamics_prediction, &
         &                     dycore_dynamics_diagnostic,     &
         &                     dycore_dynamics_diffusion 
    use dc_trace,        only: BeginSub, EndSub, DbgMessage

    implicit none

    !==== Input
    !
    type(DYCORE_DIMS), intent(in)   :: Dims   ! 次元データ全種
    type(DYCORE_VARS), intent(in)   :: Vars_b ! 格子点データ全種(t-Δt)
    type(DYCORE_VARS), intent(in)   :: Vars_n ! 格子点データ全種(t)
    !
    !==== Output
    !
    type(DYCORE_VARS), intent(inout):: Vars_a ! 格子点データ全種(t+Δt)

    !----- 作業用内部変数 -----
    character(STRING),  parameter:: subname = "dcpam_ape_dynamics"

    continue

    !----------------------------------------------------------------
    !   開始処理
    !----------------------------------------------------------------
    call BeginSub(subname)  
  
    !----------------------------------------------------------------
    !   力学演算 (水平拡散除く) 
    !----------------------------------------------------------------
    call dycore_dynamics_prediction( &
         & Dims          , &   ! intent(in)   : 次元データ全種
         & Vars_b        , &   ! intent(in)   : 格子点データ全種(t-Δt)
         & Vars_n        , &   ! intent(in)   : 格子点データ全種(t)
         & Vars_a  )           ! intent(inout): 格子点データ全種(t+Δt)

!!$    call DbgMessage('Not Calculate Dynamics.')
!!$    Vars_a%xyz_VelLon = Vars_b%xyz_VelLon  ! 速度経度成分
!!$    Vars_a%xyz_VelLat = Vars_b%xyz_VelLat  ! 速度緯度成分
!!$    Vars_a%xyz_Vor    = Vars_b%xyz_Vor   ! 渦度
!!$    Vars_a%xyz_Div    = Vars_b%xyz_Div   ! 発散
!!$    Vars_a%xyz_Temp   = Vars_b%xyz_Temp  ! 温度
!!$    Vars_a%xyz_QVap   = Vars_b%xyz_QVap  ! 比湿
!!$    Vars_a%xy_Ps      = Vars_b%xy_Ps     ! 地表面気圧

    !----------------------------------------------------------------
    !   水平拡散による時間変化
    !----------------------------------------------------------------
    call dycore_dynamics_diffusion( &
         & Vars_b    , &  ! intent(in)   : 格子点データ全種(t-Δt)
         & Vars_a  )      ! intent(inout): 格子点データ全種(t+Δt)

    !----------------------------------------------------------------
    !   診断量演算
    !----------------------------------------------------------------
    call dycore_dynamics_diagnostic( &
         & Dims            , & ! intent(in)   : 次元データ全種
         & Vars_a  )           ! intent(inout): 格子点データ全種(t+Δt)
       
    !----------------------------------------------------------------
    !   終了処理
    !----------------------------------------------------------------
    call EndSub(subname)

  end subroutine dcpam_ape_dynamics


end module dcpam_ape_dynamics_mod


