!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2005. All rights reserved.
!---------------------------------------------------------------------
!
!= Module physics_integrate_surftemp
!
!   * Developers: 
!   * Version: 
!   * Tag Name: 
!   * Change History: 
!
!== Overview
!
!DCPAM-APE time integraion of surface temprature for implicite scheme
!
!== Error Handling
!
!== Known Bugs
!
!== Note
!
!== Future Plans
!
!
  subroutine physics_integrate_surftemp( & 
    &  xy_SurfTemp, xyr_RadLFlux, xyro_DelRadLFlux, & !(inout)
    &  xyz_DVerdiffSurfTempDt, DelTime & !(in)
    &  )
    ! 
    ! 
    ! 
    use dycore_type_mod, only: STRING, INTKIND, DBKIND
    use grid_3d_mod,     only: im, jm, km
    use dc_trace,    only: BeginSub, EndSub
    implicit none
    real(DBKIND), intent(inout) :: xy_SurfTemp  ( im,jm )  !" 地表面温度
    real(DBKIND), intent(inout) :: xyr_RadLFlux ( im,jm,km+1 ) !" 長波放射
    real(DBKIND), intent(inout) :: xyro_DelRadLFlux( im,jm,km+1,0:1 )
                                    !" 地表長波フラックス補正係数 
    real(DBKIND), intent(in) :: xyz_DVerdiffSurfTempDt   ( im,jm )
                                    !" 地表温度変化率(単位時間当)
    real(DBKIND), intent(in) :: DelTime                   !" 時間刻みΔt
    character(STRING),  parameter:: subname = "physics_integrate_surftemp"
    integer(INTKIND) :: k


    ! 開始処理
    call BeginSub(subname)

    ! 1. 長波フラックスの補正 ( 地表フラックス分の補正 )  
    do k = 1, km+1
      xyr_RadLFlux(:,:,k) = xyr_RadLFlux( :,:,k ) &
        & + xyro_DelRadLFlux(:,:,k,0) * xyz_DVerdiffSurfTempDt(:,:) * DelTime
    enddo

    ! 2. 補正項係数変更 地表面放射分 その1   
    do k = 1, km+1
      xyro_DelRadLFlux (:,:,k,0) &
        & = xyro_DelRadLFlux(:,:,k,0)/xy_SurfTemp(:,:)**3 
    enddo

    ! 3. 地表面温度時間積分
    xy_SurfTemp = xy_SurfTemp + xyz_DVerdiffSurfTempDt * DelTime 

    ! 4. 補正項係数変更 地表面放射分 その2
    do k = 1, km+1
      xyro_DelRadLFlux(:,:,k,0) &
        & = xyro_DelRadLFlux(:,:,k,0 ) * xy_SurfTemp(:,:)**3 
    enddo

    ! 終了処理
    call EndSub(subname)

  end subroutine physics_integrate_surftemp

