diff_two_timeunits Subroutine

public subroutine diff_two_timeunits(tunit1, tunit2, x, dt_esmf, rc)

write(6,) ‘tunit1=’, tunit1 write(6,) ‘tunit2=’, tunit2 write(6,) ‘del sec’, sec write(6,) ‘del x’, x

Arguments

Type IntentOptional 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

Calls

proc~~diff_two_timeunits~~CallsGraph proc~diff_two_timeunits diff_two_timeunits ESMF_TimeIntervalGet ESMF_TimeIntervalGet proc~diff_two_timeunits->ESMF_TimeIntervalGet interface~mapl_assert MAPL_Assert proc~diff_two_timeunits->interface~mapl_assert interface~parse_timeunit parse_timeunit proc~diff_two_timeunits->interface~parse_timeunit proc~mapl_return MAPL_Return proc~diff_two_timeunits->proc~mapl_return proc~mapl_verify MAPL_Verify proc~diff_two_timeunits->proc~mapl_verify proc~parse_timeunit_i4 parse_timeunit_i4 interface~parse_timeunit->proc~parse_timeunit_i4 proc~parse_timeunit_i8 parse_timeunit_i8 interface~parse_timeunit->proc~parse_timeunit_i8 at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception proc~parse_timeunit_i4->interface~parse_timeunit proc~parse_timeunit_i4->proc~mapl_return proc~parse_timeunit_i4->proc~mapl_verify proc~parse_timeunit_i8->interface~mapl_assert proc~parse_timeunit_i8->proc~mapl_return proc~parse_timeunit_i8->proc~mapl_verify ESMF_TimeIntervalSet ESMF_TimeIntervalSet proc~parse_timeunit_i8->ESMF_TimeIntervalSet ESMF_TimeSet ESMF_TimeSet proc~parse_timeunit_i8->ESMF_TimeSet

Source Code

  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