dtimer_stop Subroutine

private impure subroutine dtimer_stop(this, nloops, message, print, color)

Stops the timer and calculates the elapsed time. Optionally, it can print a message along with the elapsed time.

Type Bound

timer

Arguments

Type IntentOptional Attributes Name
class(timer), intent(inout) :: this
integer, intent(in), optional :: nloops
character(len=*), intent(in), optional :: message
logical, intent(in), optional :: print
character(len=*), intent(in), optional :: color

Calls

proc~~dtimer_stop~~CallsGraph proc~dtimer_stop timer%dtimer_stop proc~print_time print_time proc~dtimer_stop->proc~print_time proc~to_seconds to_seconds proc~dtimer_stop->proc~to_seconds colorize colorize proc~print_time->colorize

Called by

proc~~dtimer_stop~~CalledByGraph proc~dtimer_stop timer%dtimer_stop program~example5 example5 program~example5->proc~dtimer_stop program~example6 example6 program~example6->proc~dtimer_stop program~test25 test25 program~test25->proc~dtimer_stop program~test26 test26 program~test26->proc~dtimer_stop program~test27 test27 program~test27->proc~dtimer_stop program~test28 test28 program~test28->proc~dtimer_stop program~test29 test29 program~test29->proc~dtimer_stop program~test30 test30 program~test30->proc~dtimer_stop

Source Code

   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