get_obsfile_Tbracket_from_epoch Subroutine

public subroutine get_obsfile_Tbracket_from_epoch(currTime, obsfile_start_time, obsfile_end_time, obsfile_interval, epoch_frequency, obsfile_Ts_index, obsfile_Te_index, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Time), intent(in) :: currTime
type(ESMF_Time), intent(in) :: obsfile_start_time
type(ESMF_Time), intent(in) :: obsfile_end_time
type(ESMF_TimeInterval), intent(in) :: obsfile_interval
type(ESMF_TimeInterval), intent(in) :: epoch_frequency
integer, intent(out) :: obsfile_Ts_index
integer, intent(out) :: obsfile_Te_index
integer, intent(out), optional :: rc

Calls

proc~~get_obsfile_tbracket_from_epoch~~CallsGraph proc~get_obsfile_tbracket_from_epoch get_obsfile_Tbracket_from_epoch ESMF_TimeIntervalGet ESMF_TimeIntervalGet proc~get_obsfile_tbracket_from_epoch->ESMF_TimeIntervalGet ESMF_TimeIntervalSet ESMF_TimeIntervalSet proc~get_obsfile_tbracket_from_epoch->ESMF_TimeIntervalSet proc~mapl_return MAPL_Return proc~get_obsfile_tbracket_from_epoch->proc~mapl_return 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

Source Code

  subroutine get_obsfile_Tbracket_from_epoch(currTime, &
       obsfile_start_time, obsfile_end_time, obsfile_interval, &
       epoch_frequency, obsfile_Ts_index, obsfile_Te_index, rc)
    implicit none
    type(ESMF_Time), intent(in) :: currTime
    type(ESMF_Time), intent(in) :: obsfile_start_time, obsfile_end_time
    type(ESMF_TimeInterval), intent(in) :: obsfile_interval, epoch_frequency
    integer, intent(out) :: obsfile_Ts_index
    integer, intent(out) :: obsfile_Te_index
    integer, optional, intent(out) :: rc

    type(ESMF_Time) :: T1
    type(ESMF_Time) :: cT1
    type(ESMF_Time) :: Ts, Te
    type(ESMF_TimeInterval) :: dT1, dT2, dTs, dTe
    real(ESMF_KIND_R8) :: dT0_s, dT1_s, dT2_s
    real(ESMF_KIND_R8) :: s1, s2
    integer :: n1, n2
    integer :: status

    !
    !  o---------o ------------- o -------------o
    !             obsfile_interval
    !               x---------------------x--
    !                       Epoch
    !

    T1 = obsfile_start_time

    cT1 = currTime
    dT1 = currTime - T1
    dT2 = currTime + epoch_frequency - T1

    call ESMF_TimeIntervalGet(obsfile_interval, s_r8=dT0_s, rc=status)
    call ESMF_TimeIntervalGet(dT1, s_r8=dT1_s, rc=status)
    call ESMF_TimeIntervalGet(dT2, s_r8=dT2_s, rc=status)
    n1 = floor (dT1_s / dT0_s)
    n2 = floor (dT2_s / dT0_s)
    s1 = n1 * dT0_s
    s2 = n2 * dT0_s
    call ESMF_TimeIntervalSet(dTs, s_r8=s1, rc=status)
    call ESMF_TimeIntervalSet(dTe, s_r8=s2, rc=status)
    Ts = T1 + dTs
    Te = T1 + dTe

    obsfile_Ts_index = n1 - 1   ! downshift by 1
    obsfile_Te_index = n2

    _RETURN(ESMF_SUCCESS)

  end subroutine get_obsfile_Tbracket_from_epoch