!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2004. All rights reserved.
!---------------------------------------------------------------------
                                                                 !=begin
!= Subroutine Radiation
!
!   * Developer: KITAMORI Taichi 
!   * Version: $ 
!   * Tag Name: $Name: arare3m-20051114 $
!   * Change History: 
!
!== Overview 
!
!放射加熱を計算する. 一様冷却を与えるだけである. 
! 
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!  
!
!== Future Plans
!
                                                                 !=end
subroutine Radiation(ss_Exner_bl, ss_ExnerBasicZ, ss_QRad)

  !==Dependency
  use dc_trace, only: BeginSub, EndSub  
  use gridset,  only: DimXMin, DimXMax, DimZMin, DimZMax, RegZMin, RegZMax, s_Z
  use physset,  only: DayTime

  !==暗黙の型宣言を禁止
  implicit none
  
  !==Input
  real(8), intent(in)   :: ss_Exner_bl(DimXMin:DimXMax, DimZMin:DimZMax)
  real(8), intent(in)   :: ss_ExnerBasicZ(DimXMin:DimXMax, DimZMin:DimZMax)

  !==Output
  real(8), intent(out)  :: ss_QRad(DimXMin:DimXMax, DimZMin:DimZMax)
  
  !==Work
  real(8), parameter    :: RadHeatRate  = - 50.0d0     ! 一様放射加熱率 [K/day]
  real(8), parameter    :: RadHeightMax = 5000.0d0     ! 一様放射加熱が存在する領域の最大高度 [m]
  integer               :: k                           ! ループ変数

  call BeginSub("Radiation", &
&           fmt="%c",        &
&           c1="Calculate radiational heating (ss_QRad).")

  do k = RegZMin, RegZMax
     if ( s_Z(k) <= RadHeightMax ) then
        ss_QRad(DimXMin:DimXMax, k) = RadHeatRate   &
             & / (     & 
             &     (     & 
             &         ss_ExnerBasicZ(DimXMin:DimXMax, k)   & 
             &       + ss_Exner_bl(DimXMin:DimXMax, k)      &
             &     ) * DayTime    &
             &   )
     else
        ss_QRad(DimXMin:DimXMax, k) =   - 0.0d0
     end if
  end do

  call EndSub("Radiation")

end subroutine Radiation

