-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchclock.f90
More file actions
52 lines (28 loc) · 885 Bytes
/
benchclock.f90
File metadata and controls
52 lines (28 loc) · 885 Bytes
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
module benchclock
implicit none
logical, save, private :: firstcall = .true.
double precision, save, private :: ticktime = 0.0
integer, parameter :: int32kind = selected_int_kind( 9)
integer, parameter :: int64kind = selected_int_kind(18)
!
! Select high resolution clock
!
integer, parameter :: intkind = int64kind
integer(kind = intkind) :: clkcount, clkrate
contains
double precision function benchtime()
double precision :: dummy
! Ensure clock is initialised
if (firstcall) dummy = benchtick()
call system_clock(clkcount)
benchtime = dble(clkcount)*ticktime
end function benchtime
double precision function benchtick()
if (firstcall) then
firstcall = .false.
call system_clock(clkcount, clkrate)
ticktime = 1.0d0/dble(clkrate)
end if
benchtick = ticktime
end function benchtick
end module benchclock