TIMERS: Rewrite slightly.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2013-12-11 17:18:56 -02:00
parent ad15dec7cd
commit e2c80a5552
2 changed files with 50 additions and 17 deletions

View File

@ -68,9 +68,10 @@ program amun
use random , only : initialize_random, finalize_random use random , only : initialize_random, finalize_random
use refinement , only : initialize_refinement use refinement , only : initialize_refinement
use schemes , only : initialize_schemes, finalize_schemes use schemes , only : initialize_schemes, finalize_schemes
use timers , only : initialize_timers, start_timer, stop_timer & use timers , only : initialize_timers, finalize_timers
, set_timer, get_timer, get_timer_total & use timers , only : start_timer, stop_timer, set_timer, get_timer
, timer_enabled, timer_description, ntimers use timers , only : get_timer_total, timer_enabled, timer_description
use timers , only : ntimers
! module variables are not implicit by default ! module variables are not implicit by default
! !
@ -145,7 +146,7 @@ program amun
! !
iterm = 0 iterm = 0
! initialize module TIMES ! initialize module TIMERS
! !
call initialize_timers() call initialize_timers()
@ -769,6 +770,10 @@ program amun
! !
call finalize_mpitools() call finalize_mpitools()
! finalize module TIMERS
!
call finalize_timers()
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
end program end program

View File

@ -23,8 +23,10 @@
!! !!
!! module: TIMERS !! module: TIMERS
!! !!
!! This module handles the execution time counting for different parts of the !! This module handles the execution time counting. Its general
!! program. !! implementation allows to insert up to 128 counters which will measure
!! time spent on the execution of the bounded code block. Each timer
!! can be described.
!! !!
!!****************************************************************************** !!******************************************************************************
! !
@ -50,8 +52,9 @@ module timers
! declare public subroutines and variables ! declare public subroutines and variables
! !
public :: initialize_timers, set_timer, start_timer, stop_timer, get_timer & public :: initialize_timers, finalize_timers
, get_timer_total, ntimers, timer_enabled, timer_description public :: set_timer, start_timer, stop_timer, get_timer, get_timer_total
public :: ntimers, timer_enabled, timer_description
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! !
@ -65,6 +68,7 @@ module timers
! Subroutine initializes module TIMERS and allocates memory to store ! Subroutine initializes module TIMERS and allocates memory to store
! execution times. ! execution times.
! !
!
!=============================================================================== !===============================================================================
! !
subroutine initialize_timers() subroutine initialize_timers()
@ -99,7 +103,7 @@ module timers
! prepare the conversion factor ! prepare the conversion factor
! !
conv = 1.0d0 / ticks conv = 1.0d+00 / max(1, ticks)
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -107,6 +111,29 @@ module timers
! !
!=============================================================================== !===============================================================================
! !
! subroutine FINALIZE_TIMERS:
! --------------------------
!
! Subroutine finalizes module.
!
!
!===============================================================================
!
subroutine finalize_timers()
! local variables are not implicit by default
!
implicit none
!
!-------------------------------------------------------------------------------
!
!-------------------------------------------------------------------------------
!
end subroutine finalize_timers
!
!===============================================================================
!
! subroutine SET_TIMER: ! subroutine SET_TIMER:
! -------------------- ! --------------------
! !
@ -138,7 +165,7 @@ module timers
! check if the timer didn't exceed the number of avalaible timers ! check if the timer didn't exceed the number of avalaible timers
! !
if (ntimer .le. ntimers) then if (ntimer <= ntimers) then
! set the timer description ! set the timer description
! !
@ -216,7 +243,7 @@ module timers
! !
call system_clock(tstop(timer)) call system_clock(tstop(timer))
times(timer) = times(timer) + tstop(timer) - tstart(timer) times(timer) = times(timer) + (tstop(timer) - tstart(timer))
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -352,6 +379,7 @@ module timers
! !
! Function returns the total execution time. ! Function returns the total execution time.
! !
!
!=============================================================================== !===============================================================================
! !
function get_timer_total() function get_timer_total()
@ -376,7 +404,7 @@ module timers
! estimate the total execution time ! estimate the total execution time
! !
get_timer_total = conv * max(1, tend - tbegin) get_timer_total = conv * max(0, tend - tbegin)
! return the value ! return the value
! !