-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtiming.f90
70 lines (58 loc) · 1.22 KB
/
timing.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
! Module for timing passages of code.
!
! Example:
!
! use timing
! implicit none
! timer_state::my_timer
!
! call timer_init(my_timer)
! call timer_start(my_timer)
! ... do stuff ...
! call timer_stop(my_timer)
! call timer_output(<file>, my_timer, "my_timer")
module timing
implicit none
type timer_state
integer::count
real(kind=8)::start
real(kind=8)::sum
end type timer_state
end module timing
subroutine timer_init(timer)
use timing
implicit none
type(timer_state)::timer
timer%count = 0
timer%start = 0.0
timer%sum = 0.0
end subroutine
subroutine timer_start(timer)
use timing
use mpi_mod
implicit none
type(timer_state)::timer
integer::info
timer%start = MPI_WTIME()
end subroutine
subroutine timer_stop(timer)
use timing
use mpi_mod
implicit none
type(timer_state)::timer
real(kind=8)::end
integer::info
if (timer%start.le.0.0) return
end = MPI_WTIME()
timer%sum = timer%sum + end - timer%start
timer%count = timer%count + 1
end subroutine
subroutine timer_inc_count(timer, delta)
use timing
use mpi_mod
implicit none
type(timer_state)::timer
integer::delta
if (timer%start.le.0.0) return
timer%count = timer%count + delta
end subroutine