!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2005. All rights reserved.
!---------------------------------------------------------------------
!= Module Advection
!
!   * Developer: SUGIYAMA Ko-ichiro
!   * Version: $Id: $
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview
!
!移流計算を行うための関数を束ねたモジュール
! 
!== Error Handling
!
!== Bugs
!
!== Note
!
!== Future Plans
!
!

module Advection

  interface ss_AdvX_ss_fs
    function ss_AdvX_ss_fs(ss_Scalar, fs_VelX)
      use gridset
      real(8), intent(in) :: fs_VelX(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !水平風速
      real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
      real(8)             :: ss_AdvX_ss_fs(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量の水平移流
    end function ss_AdvX_ss_fs
  end interface

  interface ss_AdvZ_ss_sf    
    function ss_AdvZ_ss_sf(ss_Scalar, sf_VelZ)
      use gridset
      real(8), intent(in) :: sf_VelZ(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !鉛直風速
      real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
      real(8)             :: ss_AdvZ_ss_sf(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量の鉛直移流
    end function ss_AdvZ_ss_sf
  end interface

end module Advection


function ss_AdvX_ss_fs(ss_Scalar, fs_VelX)
  !
  ! スカラー量の水平移流を計算
  !
  use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
  use average,  only: ss_avr_fs, ss_avr_fs
  use differentiate_center4, only: fs_dx_ss
  implicit none
  
  real(8), intent(in) :: fs_VelX(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !水平風速
  real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
  real(8)             :: ss_AdvX_ss_fs(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量の水平移流
  
  ss_AdvX_ss_fs = 0.0d0  !初期化
  ss_AdvX_ss_fs = ss_avr_fs(fs_VelX * fs_dx_ss(ss_Scalar))
  
end function ss_AdvX_ss_fs


function ss_AdvZ_ss_sf(ss_Scalar, sf_VelZ)
  !
  ! スカラー量の鉛直移流を計算
  !
  use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
  use average,  only: ss_avr_fs, ss_avr_sf
  use differentiate_center4, only: sf_dz_ss
  implicit none
  
  real(8), intent(in) :: sf_VelZ(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !鉛直風速
  real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
  real(8)             :: ss_AdvZ_ss_sf(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量の鉛直移流
  
  ss_AdvZ_ss_sf = 0.0d0  !初期化
  ss_AdvZ_ss_sf = ss_avr_sf(sf_VelZ * sf_dz_ss(ss_Scalar))
  
end function ss_AdvZ_ss_sf

  
  
  
