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 | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(timer), | intent(inout) | :: | this |
Timer instance previously started with |
||
| 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 |
|
| logical, | intent(in), | optional | :: |
Optional output switch; defaults to |
||
| 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. |
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