source: CIVL/examples/omp/nas-dc/common/timers.f@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

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