synchronize Function

private recursive function synchronize(self, master, wall) result(ok)

Follow master's time (it must stay alive while synchronized), or stop following (master not associated, or this clock itself), keeping the master's current time and settings. Returns false, and changes nothing, if this would make a cycle.

Type Bound

SimulationClock

Arguments

Type IntentOptional Attributes Name
class(SimulationClock), intent(inout), target :: self
type(SimulationClock), intent(in), pointer :: master

the clock to follow (null: stop following)

real(kind=wp), intent(in), optional :: wall

wall time (s; default: wall_time())

Return Value logical


Calls

proc~~synchronize~~CallsGraph proc~synchronize SimulationClock%synchronize proc~synchronize->proc~synchronize proc~is_paused SimulationClock%is_paused proc~synchronize->proc~is_paused proc~same_clock same_clock proc~synchronize->proc~same_clock proc~set_time~4 SimulationClock%set_time proc~synchronize->proc~set_time~4 proc~time_range~4 SimulationClock%time_range proc~synchronize->proc~time_range~4 proc~time_scale~2 SimulationClock%time_scale proc~synchronize->proc~time_scale~2 proc~is_paused->proc~is_paused proc~set_time~4->proc~set_time~4 proc~now now proc~set_time~4->proc~now proc~time_range~4->proc~time_range~4 proc~time_scale~2->proc~time_scale~2 proc~wall_time wall_time proc~now->proc~wall_time

Source Code

    recursive logical function synchronize(self, master, wall) result(ok)
        class(SimulationClock), intent(inout), target :: self
        type(SimulationClock), pointer, intent(in) :: master    !! the clock to follow (null: stop following)
        real(wp), intent(in), optional :: wall      !! wall time (s; default: wall_time())
        type(SimulationClock), pointer :: c
        real(wp) :: t
        ok = .true.
        if (.not. associated(master)) then
            if (associated(self%sync)) then
                t = self%sync%time()
                self%scale_ = self%sync%time_scale()
                self%paused_ = self%sync%is_paused()
                call self%sync%time_range(self%t_min, self%t_max)
                self%sync => null()
                call self%set_time(t, wall)
            end if
            return
        end if
        if (same_clock(master, self)) then
            ok = self%synchronize(null(), wall)
            return
        end if
        c => master
        do while (associated(c))
            if (same_clock(c, self)) then
                ok = .false.
                return
            end if
            c => c%sync
        end do
        self%sync => master
    end function synchronize