write(6,) ‘tunit1=’, tunit1 write(6,) ‘tunit2=’, tunit2 write(6,) ‘del sec’, sec write(6,) ‘del x’, x
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | tunit1 | |||
character(len=*), | intent(in) | :: | tunit2 | |||
real(kind=ESMF_KIND_R8), | intent(out) | :: | x | |||
type(ESMF_TimeInterval), | intent(out), | optional | :: | dt_esmf | ||
integer, | intent(out), | optional | :: | rc |
subroutine diff_two_timeunits (tunit1, tunit2, x, dt_esmf, rc) character(len=*), intent(in) :: tunit1 character(len=*), intent(in) :: tunit2 real(ESMF_KIND_R8), intent(out) :: x type(ESMF_TimeInterval), optional, intent(out) :: dt_esmf integer, intent(out), optional :: rc type(ESMF_Time) :: t1_base type(ESMF_TimeInterval) :: dt1 type(ESMF_Time) :: t2_base type(ESMF_TimeInterval) :: dt2 type(ESMF_TimeInterval) :: deltaT_base integer(ESMF_KIND_I8) :: n1 integer(ESMF_KIND_I8) :: n2 character(len=20) :: s_unit integer :: i, status, sec n1=0; n2=0 call parse_timeunit (tunit1, n1, t1_base, dt1, _RC) call parse_timeunit (tunit2, n2, t2_base, dt2, _RC) deltaT_base = t2_base - t1_base if (present(dt_esmf)) dt_esmf = deltaT_base i=index(trim(tunit1), 'since') s_unit=trim(tunit1(1:i-1)) call ESMF_TimeIntervalGet(deltaT_base, s=sec, _RC) if (trim(s_unit) == 'seconds') then x = sec elseif (trim(s_unit) == 'minutes') then x = sec / 60.d0 elseif (trim(s_unit) == 'hours') then x = sec /3600.d0 else _FAIL ('time_unit not implemented') end if !!write(6,*) 'tunit1=', tunit1 !!write(6,*) 'tunit2=', tunit2 !!write(6,*) 'del sec', sec !!write(6,*) 'del x', x _RETURN(ESMF_SUCCESS) end subroutine diff_two_timeunits