Class timer_class
In: LatticeClass/timer_class.F90
constants_module omp_lib comlib lattice_class timer_class dot/f_251.png

Defines timer class

provides timer counter (counts on all nodes) uses CPU_TIME (fortran95 intrinsic) if you want more precise counter, change CPU_TIME.

Version

$Id: timer_class.F90,v 1.20 2011/06/13 14:09:56 ishikawa Exp $

Methods

delete   get_elapse   get_interval   new   tic   timer   toc  

Included Modules

constants_module omp_lib comlib lattice_class

Public Instance methods

Subroutine :
this :type(timer), intent(inout)

delete timer

[Source]

subroutine delete_timer(this)
!
! \delete \timer
!
  implicit none
  type(timer), intent(inout) :: this
  call new(this)
  return
end subroutine
Function :
elapse :real(DP)
this :type(timer), intent(inout)

return elapse time of the timer

[Source]

function get_elapse_timer(this) result(elapse)
!
! return elapse time of the \timer
!
  use comlib
  implicit none
  type(timer), intent(inout) :: this
  real(DP) :: elapse
  call average_timer(this)
  elapse = this%elapse
  return
end function
Function :
interval :real(DP)
this :type(timer), intent(inout)

return interval time from first tick

[Source]

function get_interval_timer(this) result(interval)
!
! return interval time from first tick
!
  use comlib
  use lattice_class, only : NPU
  implicit none
  type(timer), intent(inout) :: this
  real(DP) :: interval
  interval = this%interval
#ifndef _singlePU
  if (.not.this%master_only) then
    if (NPU > 1) then
      call comlib_sumcast(interval)
    endif
  endif
#endif
  return
end function
Subroutine :
this :type(timer), intent(inout)
master_only :logical, optional, intent(in)

initialize timer

[Source]

subroutine new_timer(this,master_only)
!
! initialize \timer
!
  implicit none
  type(timer),       intent(inout) :: this
  logical, optional, intent(in)    :: master_only
  this%time0=0.0_DP
  this%time1=0.0_DP
  this%elapse=0.0_DP
  this%interval=0.0_DP
  this%ticked = 0
  this%tocked = 0
  if (present(master_only)) then
    this%master_only = master_only
  else
    this%master_only = .false.
  endif
  return
end subroutine
Subroutine :
this :type(timer), intent(inout)

tick

ifdef _OPENMP

[Source]

subroutine tic(this)
!
! tick
!
#ifdef _OPENMP
  use omp_lib
#endif
  implicit none
  type(timer), intent(inout) :: this
  real(SP) :: time

#ifdef _OPENMP
  this%time0 = omp_get_wtime()
#else
  call CPU_TIME(time)
  this%time0 = real(time,kind=KIND(1.0_DP))
#endif
  this%ticked = 1
  this%tocked = 0

  return
end subroutine
timer
Derived Type :

timer object

Subroutine :
this :type(timer), intent(inout)

tock

ifdef _OPENMP

[Source]

subroutine toc(this)
!
! tock
!
#ifdef _OPENMP
  use omp_lib
#endif
  implicit none
  type(timer), intent(inout) :: this
  real(SP) :: time

#ifdef _OPENMP
  this%time1 = omp_get_wtime()
#else
  call CPU_TIME(time)
  this%time1 = real(time,kind=DP)
#endif
  this%interval = this%time1-this%time0
  if (this%ticked == 1) then
    this%elapse = this%elapse+this%time1-this%time0
  endif
  this%ticked = 0
  this%tocked = 1

  return
end subroutine