!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Subroutine Buoyancy
!
!   * Developer: SUGIYAMA Ko-ichiro (sugiyama@gfd-dennou.org)
!   * Version: $Id$ 
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview 
!
!Z 方向の運動方程式に含まれる浮力項の計算. 
!音波に関連しない項とみなし長い時間ステップで評価
!
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!== Future Plans
!
                                                                 !=end

subroutine Buoyancy(ss_PotTemp_n, sf_Buoy_n)
                                                                 !=begin
  !== Dependency
  use gridset,  only: DimXMin, DimXMax, DimZMin, DimZMax
  use basicset, only: ss_PotTempBasicZ
  use arareprm, only: Grav
  use average,  only: sf_avr_ss
                                                                 !=end  
  !--- 暗黙の型宣言禁止
  implicit none
                                                                 !=begin  
  !== Input
  real(8), intent(in) :: ss_PotTemp_n(DimXMin:DimXMax, DimZMin:DimZMax) !温位

  !== Output
  real(8), intent(out) :: sf_Buoy_n(DimXMin:DimXMax, DimZMin:DimZMax) !浮力
                                                                 !=end 
  
  !--- 浮力項 
  sf_Buoy_n = sf_avr_ss( ( Grav * ss_PotTemp_n  / ss_PotTempBasicZ ) )

end subroutine Buoyancy
