This internal helper builds a runtime format from rfmt, colorizes the
label and unit suffix with FACE, and writes to output_unit. Formatting
errors are reported through error_unit; ok tells callers whether the
write completed successfully.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=rk), | intent(in) | :: | time |
Timing value in seconds. |
||
| character(len=*), | intent(in) | :: | message |
Label printed before |
||
| character(len=*), | intent(in), | optional | :: | color |
Optional FACE foreground color; defaults to |
|
| character(len=*), | intent(in), | optional | :: | rfmt |
Optional Fortran real edit descriptor; defaults to |
|
| logical, | intent(out) | :: | ok |
True when the formatted write completed successfully. |
subroutine print_time(time, message, color, rfmt, ok) use face, only: colorize real(rk), intent(in) :: time !! Timing value in seconds. character(*), intent(in) :: message !! Label printed before `time`. character(*), intent(in), optional :: color !! Optional FACE foreground color; defaults to `blue`. character(*), intent(in), optional :: rfmt !! Optional Fortran real edit descriptor; defaults to `F16.9`. logical, intent(out) :: ok !! True when the formatted write completed successfully. character(len=:), allocatable :: color_ !! Effective FACE color name. character(len=:), allocatable :: fmt !! Complete runtime format built from `rfmt_`. character(len=:), allocatable :: rfmt_ !! Effective real edit descriptor after trimming and defaulting. integer :: ios !! I/O status returned by the formatted write. character(len=256) :: iomsg !! Diagnostic message returned by the formatted write. ok = .false. if (present(rfmt)) then rfmt_ = adjustl(trim(rfmt)) else rfmt_ = 'F16.9' end if if (len_trim(rfmt_) == 0) then write(error_unit, '(A)') 'Error: rfmt must not be empty' return end if if (present(color)) then color_ = trim(color) else color_ = 'blue' end if fmt = '(A, ' // trim(rfmt_) // ', A)' write(output_unit, fmt, iostat=ios, iomsg=iomsg) & colorize(trim(message), color_fg=color_), time, colorize(' [s]', color_fg=color_) if (ios /= 0) then write(error_unit, '(A)') 'Error writing formatted time: ' // trim(iomsg) return end if ok = .true. end subroutine print_time