tem_time_subtract_time Function

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

Subtract right time definition from left (provides the minus operator).

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

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_subtract_time~~CalledByGraph proc~tem_time_subtract_time tem_time_subtract_time interface~operator(-) operator(-) interface~operator(-)->proc~tem_time_subtract_time

Contents


Source Code

  elemental function tem_time_subtract_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) ) then
      if (right%sim < nvrReal) then
         res%sim = left%sim - right%sim
      else
         res%sim = left%sim
      end if
    else
      res%sim = nvrReal
    end if

    if ( (left%iter  < nvrInt) ) then
      if (right%iter < nvrInt) then
         res%iter = left%iter - right%iter
      else
         res%iter = left%iter
      end if
    else
      res%iter = nvrInt
    end if

    if ( (left%clock  < nvrReal) ) then
      if (right%clock < nvrReal) then
         res%clock = left%clock - right%clock
      else
         res%clock = left%clock
      end if
    else
      res%clock = nvrReal
    end if

  end function tem_time_subtract_time