ctimer_stop Subroutine

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

Stops the timer and calculates the CPU time. Optionally, it can print a message along with the CPU 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~~ctimer_stop~~CallsGraph proc~ctimer_stop timer%ctimer_stop proc~print_time print_time proc~ctimer_stop->proc~print_time colorize colorize proc~print_time->colorize

Called by

proc~~ctimer_stop~~CalledByGraph proc~ctimer_stop timer%ctimer_stop program~example3 example3 program~example3->proc~ctimer_stop program~example4 example4 program~example4->proc~ctimer_stop program~test16 test16 program~test16->proc~ctimer_stop program~test17 test17 program~test17->proc~ctimer_stop program~test18 test18 program~test18->proc~ctimer_stop program~test4 test4 program~test4->proc~ctimer_stop program~test5 test5 program~test5->proc~ctimer_stop program~test6 test6 program~test6->proc~ctimer_stop

Source Code

   impure subroutine ctimer_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 cpu_time(this%cpu_end)

      ! Calculate the elapsed CPU time
      this%cpu_elapsed = this%cpu_end - this%cpu_start

      ! Convert CPU time to seconds
      if (.not.present(nloops)) this%cpu_time = this%cpu_elapsed
      if (     present(nloops)) this%cpu_time = this%cpu_elapsed / real(nloops, kind=rk)

      ! Print the elapsed time
      if (.not. present(message)) then
         msg = "CPU time:"
      else
         msg = message
      end if

      if (present(print)) then
         if (print) call print_time(this%cpu_time, msg, color)
      else
         call print_time(this%cpu_time, msg, color)
      end if

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

   end subroutine ctimer_stop