get_total_time Function

public function get_total_time(proc_timer, t_elapsed)


Type IntentOptional Attributes Name
type(timer) :: proc_timer
logical, optional :: t_elapsed

Return Value real(kind=dp)


Source Code

Source Code

    real(dp) function get_total_time(proc_timer, t_elapsed)
        != Return the (current) total time for a given timed procedure.
        != By default this does not include the elapsed time of the current
        != run of proc_timer's routine, so if proc_timer is active then
        != the default call to get_total_time returns the time dpent in
        != proc_timer%timer_name up to the most recent call.
        != In:
        !=   proc_timer: the timer object of the procedure.  Must be intialised by
        !=               set_timer.
        !=   t_elapsed(optional): include the elapsed time.  Warning: involves an
        !=               additional call to etime, so will affect performance if
        !=               called large numbers (10s of millions) of times.
        type(timer) :: proc_timer
        logical, optional :: t_elapsed
        real(dp) :: t

        if (time_at_all) then
            if (.not. associated(proc_timer%store)) then
                call warning_neci('get_total_time.', 'proc_timer not intialised: '//adjustl(proc_timer%timer_name))
                get_total_time = -1000.0_dp ! Helpfully return insane value, so it is obvious something went wrong. ;-)
                get_total_time = proc_timer%store%sum_time_cpu
                if (present(t_elapsed)) then
                    if (t_elapsed) then
                        t = MPI_WTIME()
                        get_total_time = get_total_time + t - proc_timer%store%time_cpu
                    end if
                end if
            end if
         end if

    end function get_total_time