dtimer_stop Subroutine

private subroutine dtimer_stop(this, nloops, message, print, color, rfmt)

dtimer_stop captures date_and_time immediately, converts the stop value to UTC epoch seconds, validates that dtimer_start was called, optionally averages and prints the duration, and writes the finalized value to elapsed_dtime.

Type Bound

timer

Arguments

Type IntentOptional Attributes Name
class(timer), intent(inout) :: this

Timer instance previously started with dtimer_start.

integer, intent(in), optional :: nloops

Optional positive loop count used to compute average date/time duration.

character(len=*), intent(in), optional :: message

Optional output label; defaults to Elapsed time:.

logical, intent(in), optional :: print

Optional output switch; defaults to .true..

character(len=*), intent(in), optional :: color

Optional FACE foreground color used for printed output.

character(len=*), intent(in), optional :: rfmt

Optional Fortran real edit descriptor used for printed output.


Calls

proc~~dtimer_stop~~CallsGraph proc~dtimer_stop timer%dtimer_stop proc~epoch_seconds_utc epoch_seconds_utc proc~dtimer_stop->proc~epoch_seconds_utc proc~finalize_timing finalize_timing proc~dtimer_stop->proc~finalize_timing proc~days_from_civil days_from_civil proc~epoch_seconds_utc->proc~days_from_civil proc~print_time print_time proc~finalize_timing->proc~print_time colorize colorize proc~print_time->colorize

Called by

proc~~dtimer_stop~~CalledByGraph proc~dtimer_stop timer%dtimer_stop proc~run_test25 run_test25 proc~run_test25->proc~dtimer_stop proc~run_test26 run_test26 proc~run_test26->proc~dtimer_stop proc~run_test27 run_test27 proc~run_test27->proc~dtimer_stop proc~run_test28 run_test28 proc~run_test28->proc~dtimer_stop proc~run_test29 run_test29 proc~run_test29->proc~dtimer_stop proc~run_test30 run_test30 proc~run_test30->proc~dtimer_stop program~example5 example5 program~example5->proc~dtimer_stop program~example6 example6 program~example6->proc~dtimer_stop program~check check program~check->proc~run_test25 program~check->proc~run_test26 program~check->proc~run_test27 program~check->proc~run_test28 program~check->proc~run_test29 program~check->proc~run_test30

Source Code

   subroutine dtimer_stop(this, nloops, message, print, color, rfmt)
      class(timer), intent(inout) :: this
         !! Timer instance previously started with `dtimer_start`.
      integer, intent(in), optional :: nloops
         !! Optional positive loop count used to compute average date/time duration.
      character(*), intent(in), optional :: message
         !! Optional output label; defaults to `Elapsed time:`.
      logical, intent(in), optional :: print
         !! Optional output switch; defaults to `.true.`.
      character(*), intent(in), optional :: color
         !! Optional FACE foreground color used for printed output.
      character(*), intent(in), optional :: rfmt
         !! Optional Fortran real edit descriptor used for printed output.

      integer :: v(8)
         !! Raw `date_and_time` values captured at stop.
      real(rk) :: t_end
         !! Stop time converted to UTC epoch seconds.
      real(rk) :: raw_seconds
         !! Raw elapsed date/time duration in seconds.
      real(rk) :: out_seconds
         !! Final date/time duration after validation and optional loop averaging.
      logical :: ok
         !! Finalization status returned by `finalize_timing`.

      call date_and_time(values=v)
      t_end = epoch_seconds_utc(v)

      if (.not. this%is_dtime_started) then
         write(error_unit, '(A)') 'Error: dtimer_stop called before dtimer_start!'
         return
      end if

      this%is_dtime_started = .false.
      raw_seconds = t_end - this%dtime_start_utc

      call finalize_timing(raw_seconds, nloops, out_seconds, 'Elapsed time:', message, print, color, rfmt, ok)
      if (.not. ok) return
      this%elapsed_dtime = out_seconds
   end subroutine dtimer_stop