Stops the timer and calculates the MPI time. Optionally, it can print a message along with the MPI 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 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