timer_get_elapsed_time Function

private function timer_get_elapsed_time(self) result(elapsed)

Returns the elapsed time as a real(dp) variable

Usage: var = my_timer%get_elapsed_time()

Needs my_timer to be declared previously as type(pic_timer_type) :: my_timer

Type Bound

pic_timer_type

Arguments

Type IntentOptional Attributes Name
class(pic_timer_type), intent(in) :: self

Return Value real(kind=dp)


Called by

proc~~timer_get_elapsed_time~~CalledByGraph proc~timer_get_elapsed_time pic_timer_type%timer_get_elapsed_time proc~flop_rate_get_flop_rate flop_rate_type%flop_rate_get_flop_rate proc~flop_rate_get_flop_rate->proc~timer_get_elapsed_time proc~flop_rate_get_time flop_rate_type%flop_rate_get_time proc~flop_rate_get_time->proc~timer_get_elapsed_time proc~timer_print_time pic_timer_type%timer_print_time proc~timer_print_time->proc~timer_get_elapsed_time proc~flop_rate_report flop_rate_type%flop_rate_report proc~flop_rate_report->proc~flop_rate_get_flop_rate

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: current_count

Source Code

   function timer_get_elapsed_time(self) result(elapsed)
      !! Returns the elapsed time as a real(dp) variable
      !!
      !! Usage: var = my_timer%get_elapsed_time()
      !!
      !! Needs my_timer to be declared previously as type(pic_timer_type) :: my_timer
      !!
      class(pic_timer_type), intent(in) :: self
      real(dp) :: elapsed
      integer(default_int) :: current_count
      elapsed = 0.0_dp
#ifdef _OPENMP
      if (self%is_running) then
         elapsed = omp_get_wtime() - self%start_time
      else
         elapsed = self%stop_time - self%start_time
      end if
#else
      if (self%is_running) then
         call system_clock(count=current_count)
         elapsed = real(current_count - self%start_count, dp)/real(self%count_rate, dp)
      else
         elapsed = real(self%stop_count - self%start_count, dp)/real(self%count_rate, dp)
      end if
#endif
   end function timer_get_elapsed_time