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.
| Type | Intent | Optional | 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 |
||
| character(len=*), | intent(in) | :: | default_label |
Backend-specific output label used when |
||
| character(len=*), | intent(in), | optional | :: | message |
Optional output label printed before the timing value. |
|
| logical, | intent(in), | optional | :: |
Optional output switch; defaults to |
||
| 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 |
|
| logical, | intent(out) | :: | ok |
True when finalization succeeds and the caller may store |
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