| 1 | c---------------------------------------------------------------------
|
|---|
| 2 | c---------------------------------------------------------------------
|
|---|
| 3 |
|
|---|
| 4 | subroutine timer_clear(n)
|
|---|
| 5 |
|
|---|
| 6 | c---------------------------------------------------------------------
|
|---|
| 7 | c---------------------------------------------------------------------
|
|---|
| 8 |
|
|---|
| 9 | implicit none
|
|---|
| 10 | integer n
|
|---|
| 11 |
|
|---|
| 12 | double precision start(64), elapsed(64)
|
|---|
| 13 | common /tt/ start, elapsed
|
|---|
| 14 | c$omp threadprivate(/tt/)
|
|---|
| 15 |
|
|---|
| 16 | elapsed(n) = 0.0
|
|---|
| 17 | return
|
|---|
| 18 | end
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | c---------------------------------------------------------------------
|
|---|
| 22 | c---------------------------------------------------------------------
|
|---|
| 23 |
|
|---|
| 24 | subroutine timer_start(n)
|
|---|
| 25 |
|
|---|
| 26 | c---------------------------------------------------------------------
|
|---|
| 27 | c---------------------------------------------------------------------
|
|---|
| 28 |
|
|---|
| 29 | implicit none
|
|---|
| 30 | external elapsed_time
|
|---|
| 31 | double precision elapsed_time
|
|---|
| 32 | integer n
|
|---|
| 33 | double precision start(64), elapsed(64)
|
|---|
| 34 | common /tt/ start, elapsed
|
|---|
| 35 | c$omp threadprivate(/tt/)
|
|---|
| 36 |
|
|---|
| 37 | start(n) = elapsed_time()
|
|---|
| 38 |
|
|---|
| 39 | return
|
|---|
| 40 | end
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | c---------------------------------------------------------------------
|
|---|
| 44 | c---------------------------------------------------------------------
|
|---|
| 45 |
|
|---|
| 46 | subroutine timer_stop(n)
|
|---|
| 47 |
|
|---|
| 48 | c---------------------------------------------------------------------
|
|---|
| 49 | c---------------------------------------------------------------------
|
|---|
| 50 |
|
|---|
| 51 | implicit none
|
|---|
| 52 | external elapsed_time
|
|---|
| 53 | double precision elapsed_time
|
|---|
| 54 | integer n
|
|---|
| 55 | double precision start(64), elapsed(64)
|
|---|
| 56 | common /tt/ start, elapsed
|
|---|
| 57 | c$omp threadprivate(/tt/)
|
|---|
| 58 | double precision t, now
|
|---|
| 59 | now = elapsed_time()
|
|---|
| 60 | t = now - start(n)
|
|---|
| 61 | elapsed(n) = elapsed(n) + t
|
|---|
| 62 |
|
|---|
| 63 | return
|
|---|
| 64 | end
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | c---------------------------------------------------------------------
|
|---|
| 68 | c---------------------------------------------------------------------
|
|---|
| 69 |
|
|---|
| 70 | double precision function timer_read(n)
|
|---|
| 71 |
|
|---|
| 72 | c---------------------------------------------------------------------
|
|---|
| 73 | c---------------------------------------------------------------------
|
|---|
| 74 |
|
|---|
| 75 | implicit none
|
|---|
| 76 | integer n
|
|---|
| 77 | double precision start(64), elapsed(64)
|
|---|
| 78 | common /tt/ start, elapsed
|
|---|
| 79 | c$omp threadprivate(/tt/)
|
|---|
| 80 |
|
|---|
| 81 | timer_read = elapsed(n)
|
|---|
| 82 | return
|
|---|
| 83 | end
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 | c---------------------------------------------------------------------
|
|---|
| 87 | c---------------------------------------------------------------------
|
|---|
| 88 |
|
|---|
| 89 | double precision function elapsed_time()
|
|---|
| 90 |
|
|---|
| 91 | c---------------------------------------------------------------------
|
|---|
| 92 | c---------------------------------------------------------------------
|
|---|
| 93 |
|
|---|
| 94 | implicit none
|
|---|
| 95 | c$ external omp_get_wtime
|
|---|
| 96 | c$ double precision omp_get_wtime
|
|---|
| 97 |
|
|---|
| 98 | double precision t
|
|---|
| 99 | logical mp
|
|---|
| 100 |
|
|---|
| 101 | c ... Use the OpenMP timer if we can (via C$ conditional compilation)
|
|---|
| 102 | mp = .false.
|
|---|
| 103 | c$ mp = .true.
|
|---|
| 104 | c$ t = omp_get_wtime()
|
|---|
| 105 |
|
|---|
| 106 | if (.not.mp) then
|
|---|
| 107 | c This function must measure wall clock time, not CPU time.
|
|---|
| 108 | c Since there is no portable timer in Fortran (77)
|
|---|
| 109 | c we call a routine compiled in C (though the C source may have
|
|---|
| 110 | c to be tweaked).
|
|---|
| 111 | call wtime(t)
|
|---|
| 112 | c The following is not ok for "official" results because it reports
|
|---|
| 113 | c CPU time not wall clock time. It may be useful for developing/testing
|
|---|
| 114 | c on timeshared Crays, though.
|
|---|
| 115 | c call second(t)
|
|---|
| 116 | endif
|
|---|
| 117 |
|
|---|
| 118 | elapsed_time = t
|
|---|
| 119 |
|
|---|
| 120 | return
|
|---|
| 121 | end
|
|---|
| 122 |
|
|---|