timer_stop Subroutine

private impure subroutine timer_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~~timer_stop~~CallsGraph proc~timer_stop timer%timer_stop proc~print_time print_time proc~timer_stop->proc~print_time colorize colorize proc~print_time->colorize

Called by

proc~~timer_stop~~CalledByGraph proc~timer_stop timer%timer_stop program~example1 example1 program~example1->proc~timer_stop program~example2 example2 program~example2->proc~timer_stop program~test1 test1 program~test1->proc~timer_stop program~test13 test13 program~test13->proc~timer_stop program~test14 test14 program~test14->proc~timer_stop program~test15 test15 program~test15->proc~timer_stop program~test2 test2 program~test2->proc~timer_stop program~test3 test3 program~test3->proc~timer_stop

Source Code

   impure subroutine timer_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 system_clock(count=this%clock_end)

      ! Calculate the elapsed processor ticks
      this%clock_elapsed = this%clock_end - this%clock_start

      ! Convert processor ticks to seconds
      if (.not.present(nloops)) &
      this%elapsed_time = real(this%clock_elapsed, kind=rk) / real(this%clock_rate, kind=rk)
      if (     present(nloops)) &
      this%elapsed_time = real(this%clock_elapsed, kind=rk) / real(this%clock_rate, kind=rk) / 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_time, msg, color)
      else
         call print_time(this%elapsed_time, msg, color)
      end if

      ! Deallocate the message
      if (allocated(msg)) deallocate(msg)

   end subroutine timer_stop