tem_time_add_time Function

private elemental function tem_time_add_time(left, right) result(res)

Add two time definitions to each other (provides the plus operator).

Entries set to huge (never) will be kept as this, all other entries are simply added to each other.

Arguments

Type IntentOptional Attributes Name
type(tem_time_type), intent(in) :: left

First operant in the addition of times.

type(tem_time_type), intent(in) :: right

Second operant in the addition of times.

Return Value type(tem_time_type)

Resulting sum of left and right.


Called by

proc~~tem_time_add_time~~CalledByGraph proc~tem_time_add_time tem_time_add_time interface~operator(+) operator(+) interface~operator(+)->proc~tem_time_add_time

Contents

Source Code


Source Code

  elemental function tem_time_add_time(left, right) result(res)
    ! -------------------------------------------------------------------- !
    !> First operant in the addition of times.
    type(tem_time_type), intent(in) :: left

    !> Second operant in the addition of times.
    type(tem_time_type), intent(in) :: right

    !> Resulting sum of left and right.
    type(tem_time_type) :: res
    ! -------------------------------------------------------------------- !
    real(kind=rk) :: nvrReal
    integer :: nvrInt
    ! -------------------------------------------------------------------- !

    nvrReal = huge(left%sim)
    nvrInt = huge(left%iter)

    if (       (left%sim  < nvrReal)            &
      &  .and. (right%sim < (nvrReal-left%sim)) ) then
      res%sim = left%sim + right%sim
    else
      res%sim = nvrReal
    end if

    if (       (left%iter  < nvrInt)             &
      &  .and. (right%iter < (nvrInt-left%iter)) ) then
      res%iter = left%iter + right%iter
    else
      res%iter = nvrInt
    end if

    if (       (left%clock  < nvrReal)              &
      &  .and. (right%clock < (nvrReal-left%clock)) ) then
      res%clock = left%clock + right%clock
    else
      res%clock = nvrReal
    end if

  end function tem_time_add_time