GCC Code Coverage Report


Directory: ./
File: src/timing.f90
Date: 2026-10-22 05:02:02
Coverage Exec Excl Total
Lines: 88.0% 22 0 25
Functions: 75.0% 3 0 4
Branches: -% 0 0 0

Line Branch Exec Source
1 module timing
2 implicit none
3
4 ! Define real(dp) kind parameter
5 integer, parameter :: dp = kind(1.0d0)
6
7 ! Timer variables (now storing clock counts)
8 integer(kind=8) :: program_start_time
9 integer(kind=8) :: phase_start_time
10 integer(kind=8) :: clock_rate
11 integer(kind=8) :: clock_max
12
13 contains
14
15 79 subroutine init_timer()
16 real(dp) :: resolution_sec, max_seconds
17
18 79 call system_clock(program_start_time, clock_rate, clock_max)
19 79 phase_start_time = program_start_time
20
21 ! Calculate resolution in seconds
22 79 resolution_sec = 1.0_dp/real(clock_rate, dp)
23
24 ! Calculate maximum time in seconds before wraparound
25 79 max_seconds = real(clock_max, dp)/real(clock_rate, dp)
26
27 ! Print timing system information
28 79 write (*, '(A)') 'INFO: Timing system initialized'
29 79 write (*, '(A,I12)') ' Clock rate (ticks per second): ', clock_rate
30 79 write (*, '(A,ES8.2,A)') ' Resolution per tick: ', resolution_sec, ' seconds'
31 79 write (*, '(A,ES8.2,A)') ' Maximum time before wraparound: ', max_seconds, ' seconds'
32 79 end subroutine init_timer
33
34 922 subroutine print_phase_time(phase_name)
35 character(*), intent(in) :: phase_name
36 integer(kind=8) :: current_time
37 real(dp) :: elapsed_sec, total_sec
38
39 922 call system_clock(current_time, clock_rate, clock_max)
40
41 ! Convert clock counts to seconds
42 922 elapsed_sec = real(current_time - phase_start_time, dp)/real(clock_rate, dp)
43 922 total_sec = real(current_time - program_start_time, dp)/real(clock_rate, dp)
44
45 922 write (*, '(A,A,F12.3,A,F12.3,A)') 'INFO: ', phase_name, elapsed_sec, &
46 1844 ' s (Total: ', total_sec, ' s)'
47
48 922 phase_start_time = current_time
49 922 end subroutine print_phase_time
50
51 ! Get current wall-clock time in seconds (replacement for omp_get_wtime)
52 58 function get_wtime() result(wtime)
53 real(dp) :: wtime
54 integer(kind=8) :: current_time
55 integer(kind=8) :: rate, max
56
57 ! Get current time with rate to ensure consistency
58 ! Note: We get rate each time in case get_wtime is called before init_timer
59 58 call system_clock(current_time, rate, max)
60 58 wtime = real(current_time, dp)/real(rate, dp)
61 58 end function get_wtime
62
63 ! Get elapsed time in seconds between two time points
64 ✗ function get_elapsed_time(start_time, end_time) result(elapsed)
65 real(dp), intent(in) :: start_time, end_time
66 real(dp) :: elapsed
67
68 ✗ elapsed = end_time - start_time
69 ✗ end function get_elapsed_time
70
71 end module timing
72