ctimer_stop Subroutine

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

ctimer_stop captures CPU time immediately, validates that ctimer_start was called, optionally averages and prints the duration, and writes the finalized value to cpu_time.

Type Bound

timer

Arguments

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

Timer instance previously started with ctimer_start.

integer, intent(in), optional :: nloops

Optional positive loop count used to compute average CPU time.

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

Optional output label; defaults to CPU 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~~ctimer_stop~~CallsGraph proc~ctimer_stop timer%ctimer_stop proc~finalize_timing finalize_timing proc~ctimer_stop->proc~finalize_timing proc~print_time print_time proc~finalize_timing->proc~print_time colorize colorize proc~print_time->colorize

Called by

proc~~ctimer_stop~~CalledByGraph proc~ctimer_stop timer%ctimer_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_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~example3 example3 program~example3->proc~ctimer_stop program~example4 example4 program~example4->proc~ctimer_stop program~check check program~check->proc~run_test16 program~check->proc~run_test17 program~check->proc~run_test18 program~check->proc~run_test4 program~check->proc~run_test5 program~check->proc~run_test6

Source Code

   subroutine ctimer_stop(this, nloops, message, print, color, rfmt)
      class(timer), intent(inout) :: this
         !! Timer instance previously started with `ctimer_start`.
      integer, intent(in), optional :: nloops
         !! Optional positive loop count used to compute average CPU time.
      character(*), intent(in), optional :: message
         !! Optional output label; defaults to `CPU 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.

      real(rk) :: cpu_end
         !! CPU time captured at stop.
      real(rk) :: raw_seconds
         !! Raw CPU duration in seconds.
      real(rk) :: out_seconds
         !! Final CPU duration after validation and optional loop averaging.
      logical :: ok
         !! Finalization status returned by `finalize_timing`.

      call cpu_time(cpu_end)

      if (.not. this%is_cpu_started) then
         write(error_unit, '(A)') 'Error: ctimer_stop called before ctimer_start!'
         return
      end if

      this%is_cpu_started = .false.
      raw_seconds = cpu_end - this%cpu_start

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