finalize_timing Subroutine

private subroutine finalize_timing(value_raw, nloops, value_out, default_label, message, print, color, rfmt, ok)

This internal helper centralizes the common stop-routine behavior. It optionally divides the raw duration by nloops, selects either the caller's message or the backend-specific default_label, respects print=.false., and returns whether the caller may update its public result component.

A present nloops value must be positive. If nloops <= 0 or printing fails, ok is returned as .false. and the caller leaves the previous stored result unchanged.

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: value_raw

Raw measured duration in seconds.

integer, intent(in), optional :: nloops

Optional positive loop count used to compute an average time per loop.

real(kind=rk), intent(out) :: value_out

Validated duration in seconds, averaged by nloops when present.

character(len=*), intent(in) :: default_label

Backend-specific output label used when message is absent.

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

Optional output label printed before the timing value.

logical, intent(in), optional :: print

Optional output switch; defaults to .true..

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

Optional FACE foreground color for the printed label and unit suffix.

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

Optional Fortran real edit descriptor used by print_time.

logical, intent(out) :: ok

True when finalization succeeds and the caller may store value_out.


Calls

proc~~finalize_timing~~CallsGraph proc~finalize_timing finalize_timing proc~print_time print_time proc~finalize_timing->proc~print_time colorize colorize proc~print_time->colorize

Called by

proc~~finalize_timing~~CalledByGraph proc~finalize_timing finalize_timing proc~ctimer_stop timer%ctimer_stop proc~ctimer_stop->proc~finalize_timing proc~dtimer_stop timer%dtimer_stop proc~dtimer_stop->proc~finalize_timing proc~timer_stop timer%timer_stop proc~timer_stop->proc~finalize_timing proc~run_test1 run_test1 proc~run_test1->proc~timer_stop proc~run_test13 run_test13 proc~run_test13->proc~timer_stop proc~run_test14 run_test14 proc~run_test14->proc~timer_stop proc~run_test15 run_test15 proc~run_test15->proc~timer_stop proc~run_test16 run_test16 proc~run_test16->proc~ctimer_stop proc~run_test17 run_test17 proc~run_test17->proc~ctimer_stop proc~run_test18 run_test18 proc~run_test18->proc~ctimer_stop proc~run_test2 run_test2 proc~run_test2->proc~timer_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_test3 run_test3 proc~run_test3->proc~timer_stop proc~run_test30 run_test30 proc~run_test30->proc~dtimer_stop proc~run_test31 run_test31 proc~run_test31->proc~timer_stop proc~run_test32 run_test32 proc~run_test32->proc~timer_stop proc~run_test4 run_test4 proc~run_test4->proc~ctimer_stop proc~run_test5 run_test5 proc~run_test5->proc~ctimer_stop proc~run_test6 run_test6 proc~run_test6->proc~ctimer_stop program~example1 example1 program~example1->proc~timer_stop program~example2 example2 program~example2->proc~timer_stop program~example3 example3 program~example3->proc~ctimer_stop program~example4 example4 program~example4->proc~ctimer_stop program~example5 example5 program~example5->proc~dtimer_stop program~example6 example6 program~example6->proc~dtimer_stop program~check check program~check->proc~run_test1 program~check->proc~run_test13 program~check->proc~run_test14 program~check->proc~run_test15 program~check->proc~run_test16 program~check->proc~run_test17 program~check->proc~run_test18 program~check->proc~run_test2 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_test3 program~check->proc~run_test30 program~check->proc~run_test31 program~check->proc~run_test32 program~check->proc~run_test4 program~check->proc~run_test5 program~check->proc~run_test6

Source Code

   subroutine finalize_timing(value_raw, nloops, value_out, default_label, message, print, color, rfmt, ok)
      real(rk), intent(in) :: value_raw
         !! Raw measured duration in seconds.
      integer, intent(in), optional :: nloops
         !! Optional positive loop count used to compute an average time per loop.
      real(rk), intent(out) :: value_out
         !! Validated duration in seconds, averaged by `nloops` when present.
      character(*), intent(in) :: default_label
         !! Backend-specific output label used when `message` is absent.
      character(*), intent(in), optional :: message
         !! Optional output label printed before the timing value.
      logical, intent(in), optional :: print
         !! Optional output switch; defaults to `.true.`.
      character(*), intent(in), optional :: color
         !! Optional FACE foreground color for the printed label and unit suffix.
      character(*), intent(in), optional :: rfmt
         !! Optional Fortran real edit descriptor used by `print_time`.
      logical, intent(out) :: ok
         !! True when finalization succeeds and the caller may store `value_out`.

      logical :: do_print
         !! Effective print flag after applying the default value.

      ok = .false.
      value_out = value_raw
      do_print = .true.
      if (present(print)) do_print = print

      if (present(nloops)) then
         if (nloops <= 0) then
            if (do_print) write(error_unit, '(A)') 'Error: nloops must be > 0'
            return
         end if
         value_out = value_out / real(nloops, rk)
      end if

      if (.not. do_print) then
         ok = .true.
         return
      end if

      if (present(message)) then
         call print_time(value_out, message, color, rfmt, ok)
      else
         call print_time(value_out, default_label, color, rfmt, ok)
      end if
   end subroutine finalize_timing