subroutine SetAlbedoMathews( xy_SurfCond, xy_SurfAlbedo )
! モジュール引用 ; USE statements
!
! 格子点設定
! Grid points settings
!
use gridset, only: imax, jmax, kmax ! 鉛直層数.
! Number of vertical level
! 日付および時刻の取り扱い
! Date and time handler
!
use dc_calendar, only: DCCalInquire, DCCalDateEvalSecOfYear
! 時刻管理
! Time control
!
use timeset, only: TimeN, InitialDate
! 宣言文 ; Declaration statements
!
integer , intent(in ) :: xy_SurfCond ( 0:imax-1, 1:jmax )
! 地表状態 (0: 固定, 1: 可変).
! Surface condition (0: fixed, 1: variable)
real(DP), intent(out) :: xy_SurfAlbedo( 0:imax-1, 1:jmax )
! 地表アルベド.
! Surface albedo
! 作業変数
! Work variables
!
real(DP):: SecOfYear
real(DP):: a_Data_SOY_Ex( 0:nseason+1 )
real(DP):: xya_SurfAlbedoLocal( 0:imax-1, 1:jmax, 1:2 )
integer :: i ! 経度方向に回る DO ループ用作業変数
! Work variables for DO loop in longitude
integer :: j ! 緯度方向に回る DO ループ用作業変数
! Work variables for DO loop in latitude
integer :: l
integer :: t
integer :: tindex
integer :: a_tindex(1:2)
integer:: hour_in_day, min_in_hour, day_in_year
integer, pointer:: day_in_month_ptr(:) => null()
real(DP):: sec_in_min, sec_in_day
! 実行文 ; Executable statement
!
if ( .not. albedo_mathews_inited ) call SetAlbedoInit
if ( flag_annual_mean ) then
!
! Now, annual mean value is used, temporarily.
!
xy_SurfAlbedo = 0.0d0
do l = 1, nseason
do j = 1, jmax
do i = 0, imax-1
xy_SurfAlbedo(i,j) = xy_SurfAlbedo(i,j) + xy_Data_Albedo( l, xy_SurfCond(i,j) )
end do
end do
end do
xy_SurfAlbedo = xy_SurfAlbedo / dble( nseason )
else
SecOfYear = DCCalDateEvalSecOfYear( TimeN, date = InitialDate )
call DCCalInquire( day_in_month_ptr = day_in_month_ptr , hour_in_day = hour_in_day , min_in_hour = min_in_hour , sec_in_min = sec_in_min ) ! (out)
day_in_year = sum( day_in_month_ptr )
deallocate( day_in_month_ptr )
sec_in_day = hour_in_day * min_in_hour * sec_in_min
if ( SecOfYear > day_in_year * sec_in_day ) SecOfYear = day_in_year * sec_in_day
a_Data_SOY_Ex(0) = ( 0.0d0 - ( day_in_year - a_Data_DOY(nseason) ) ) * sec_in_day
do t = 1, nseason
a_Data_SOY_Ex(t) = a_Data_DOY(t) * sec_in_day
end do
a_Data_SOY_Ex(nseason+1) = ( day_in_year + a_Data_DOY(1) ) * sec_in_day
a_tindex(1) = 0
a_tindex(2) = 1
do t = 1, nseason
if ( a_Data_DOY(t) * sec_in_day <= SecOfYear ) then
a_tindex(1) = t
a_tindex(2) = t+1
end if
end do
do t = 1, 2
! for northern hemisphere
tindex = a_tindex(t)
if ( tindex == 0 ) then
tindex = nseason
else if ( tindex == nseason+1 ) then
tindex = 1
else
tindex = tindex
end if
do j = jmax/2+1, jmax
do i = 0, imax-1
xya_SurfAlbedoLocal(i,j,t) = xy_Data_Albedo( tindex, xy_SurfCond(i,j) )
end do
end do
! for southern hemisphere
tindex = a_tindex(t) + nseason / 2
if ( tindex > nseason ) tindex = tindex - nseason
if ( tindex == 0 ) then
tindex = nseason
else if ( tindex == nseason+1 ) then
tindex = 1
else
tindex = tindex
end if
do j = 1, jmax/2
do i = 0, imax-1
xya_SurfAlbedoLocal(i,j,t) = xy_Data_Albedo( tindex, xy_SurfCond(i,j) )
end do
end do
end do
xy_SurfAlbedo = ( xya_SurfAlbedoLocal(:,:,2) - xya_SurfAlbedoLocal(:,:,1) ) / ( a_Data_SOY_Ex(a_tindex(2)) - a_Data_SOY_Ex(a_tindex(1)) ) * ( SecOfYear - a_Data_SOY_Ex(a_tindex(1)) ) + xya_SurfAlbedoLocal(:,:,1)
end if
end subroutine SetAlbedoMathews