Stops the timer and calculates the elapsed time. Optionally, it can print a message along with the elapsed time.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(timer), | intent(inout) | :: | this | |||
integer, | intent(in), | optional | :: | nloops | ||
character(len=*), | intent(in), | optional | :: | message | ||
logical, | intent(in), | optional | :: | |||
character(len=*), | intent(in), | optional | :: | color |
impure subroutine dtimer_stop(this, nloops, message, print, color) class(timer), intent(inout) :: this integer, intent(in), optional :: nloops character(*), intent(in), optional :: message character(:), allocatable :: msg logical, intent(in), optional :: print character(*), intent(in), optional :: color ! Stop the timer call date_and_time(values=this%values_end) ! Calculate the elapsed processor ticks this%values_elapsed = this%values_end - this%values_start ! Convert processor ticks to seconds if (.not.present(nloops)) & this%elapsed_dtime = to_seconds(this%values_elapsed) if ( present(nloops)) & this%elapsed_dtime = to_seconds(this%values_elapsed) / real(nloops, kind=rk) ! Print the elapsed time if (.not. present(message)) then msg = "Elapsed time:" else msg = message end if if (present(print)) then if (print) call print_time(this%elapsed_dtime, msg, color) else call print_time(this%elapsed_dtime, msg, color) end if ! Deallocate the message if (allocated(msg)) deallocate(msg) end subroutine dtimer_stop