mtimer_stop Subroutine

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

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

Called by

proc~~mtimer_stop~~CalledByGraph proc~mtimer_stop timer%mtimer_stop program~test10 test10 program~test10->proc~mtimer_stop program~test11 test11 program~test11->proc~mtimer_stop program~test12 test12 program~test12->proc~mtimer_stop program~test22 test22 program~test22->proc~mtimer_stop program~test23 test23 program~test23->proc~mtimer_stop program~test24 test24 program~test24->proc~mtimer_stop

Source Code

   impure subroutine mtimer_stop(this, nloops, message, print, color)
      ! include 'mpif.h'
      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

      interface
         function mpi_wtime()
            import rk
            real(rk) :: mpi_wtime
         end function mpi_wtime
      end interface

      ! Stop the timer
      this%mpi_end = mpi_wtime()

      ! Calculate the elapsed MPI time
      this%mpi_elapsed = this%mpi_end - this%mpi_start

      ! Convert MPI time to seconds
      if (.not.present(nloops)) this%mpi_time = this%mpi_elapsed
      if (     present(nloops)) this%mpi_time = this%mpi_elapsed / real(nloops, kind=rk)

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

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

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

   end subroutine mtimer_stop