Function to find a default for time, if it is not defined already.
Depending on dependency set the value in time to a zero time, if it is set to never. This is useful to find a suitable minimum, where an interval is defined in the timeControl, but no minimum.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_time_type), | intent(in) | :: | time |
The time to find a default 0 for, if not define, but dependency is. |
||
type(tem_time_type), | intent(in) | :: | dependency |
A time definition where we set a 0 default in time for, if the corresponding component is defined, but the time component is not. |
Resulting time, with zeroed components where dependency is defined, but time not.
pure function tem_time_default_zero(time, dependency) result(zeroed)
! -------------------------------------------------------------------- !
!> The time to find a default 0 for, if not define, but dependency is.
type(tem_time_type), intent(in) :: time
!> A time definition where we set a 0 default in time for, if the
!! corresponding component is defined, but the time component is
!! not.
type(tem_time_type), intent(in) :: dependency
!> Resulting time, with zeroed components where dependency is defined,
!! but time not.
type(tem_time_type) :: zeroed
! -------------------------------------------------------------------- !
zeroed = time
if (.not. time%sim < huge(time%sim)) then
! Time set to never.
if (dependency%sim < huge(dependency%sim)) then
! But dependency not!
zeroed%sim = 0.0_rk
end if
end if
if (.not. time%iter < huge(time%iter)) then
! Time set to never.
if (dependency%iter < huge(dependency%iter)) then
! But dependency not!
zeroed%iter = 0
end if
end if
if (.not. time%clock < huge(time%clock)) then
! Time set to never.
if (dependency%clock < huge(dependency%clock)) then
! But dependency not!
zeroed%clock = 0.0_rk
end if
end if
end function tem_time_default_zero