-
Notifications
You must be signed in to change notification settings - Fork 12
/
code_timer_module.F90
73 lines (51 loc) · 1.73 KB
/
code_timer_module.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
! $Id$
module code_timer_module
! Description:
! This module contains a diagnostic timer utility that can be used
! to time a piece of code.
implicit none
private ! Set default scope
! A timer!!
type timer_t
real :: time_elapsed ! Time elapsed [sec]
real :: secstart ! Timer starting time
end type timer_t
public :: timer_t, timer_start, timer_stop
contains
!-----------------------------------------------------------------------
subroutine timer_start( timer )
! Description:
! Starts the timer
! References:
! None
!-----------------------------------------------------------------------
implicit none
! Input/Output Variables
type(timer_t), intent(inout) :: timer
!-----------------------------------------------------------------------
!----- Begin Code -----
call cpu_time( timer%secstart )
return
end subroutine timer_start
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
subroutine timer_stop( timer )
! Description:
! Stops the timer
! References:
! None
!-----------------------------------------------------------------------
implicit none
! Input/Output Variables
type(timer_t), intent(inout) :: timer
! Local Variables
real :: secend
!-----------------------------------------------------------------------
!----- Begin Code -----
call cpu_time( secend )
timer%time_elapsed = timer%time_elapsed + (secend - timer%secstart)
timer%secstart = 0.0
return
end subroutine timer_stop
!-----------------------------------------------------------------------
end module code_timer_module