WAVEWATCH III  beta 0.0.1
scrip_timers Module Reference

Functions/Subroutines

subroutine timer_check (timer)
 
subroutine timer_clear (timer)
 
real(scrip_r4) function timer_get (timer)
 
subroutine timer_print (timer)
 
subroutine timer_start (timer)
 
subroutine timer_stop (timer)
 
subroutine timers_init
 

Variables

integer(scrip_i4), parameter max_timers = 99
 
integer(scrip_i4), save cycles_max
 
integer(scrip_i4), dimension(max_timers), save cycles1
 
integer(scrip_i4), dimension(max_timers), save cycles2
 
real(scrip_r4), save clock_rate
 
real(scrip_r4), dimension(max_timers), save cputime
 
character(len=8), dimension(max_timers), save status
 

Function/Subroutine Documentation

◆ timer_check()

subroutine scrip_timers::timer_check ( integer (scrip_i4), intent(in)  timer)

Definition at line 73 of file scrip_timers.f.

73 
74 !-----------------------------------------------------------------------
75 !
76 ! This routine checks a given timer. This is primarily used to
77 ! periodically accumulate time in the timer to prevent timer cycles
78 ! from wrapping around max_cycles.
79 !
80 !-----------------------------------------------------------------------
81 
82 !-----------------------------------------------------------------------
83 !
84 ! Input Variables:
85 !
86 !-----------------------------------------------------------------------
87 
88  integer (SCRIP_i4), intent(in) ::
89  & timer ! timer number
90 
91 !-----------------------------------------------------------------------
92 
93  if (status(timer) .eq. 'running') then
94  call timer_stop (timer)
95  call timer_start(timer)
96  endif
97 
98 !-----------------------------------------------------------------------
99 

References status, timer_start(), and timer_stop().

◆ timer_clear()

subroutine scrip_timers::timer_clear ( integer (scrip_i4), intent(in)  timer)

Definition at line 105 of file scrip_timers.f.

105 
106 !-----------------------------------------------------------------------
107 !
108 ! This routine resets a given timer.
109 !
110 !-----------------------------------------------------------------------
111 
112 !-----------------------------------------------------------------------
113 !
114 ! Input Variables:
115 !
116 !-----------------------------------------------------------------------
117 
118  integer (SCRIP_i4), intent(in) ::
119  & timer ! timer number
120 
121 !-----------------------------------------------------------------------
122 
123  cputime(timer) = 0.0_scrip_r4 ! clear the timer
124 
125 !-----------------------------------------------------------------------
126 

References cputime.

Referenced by scrip_interface::scrip().

◆ timer_get()

real (scrip_r4) function scrip_timers::timer_get ( integer (scrip_i4), intent(in)  timer)

Definition at line 132 of file scrip_timers.f.

132 
133 !-----------------------------------------------------------------------
134 !
135 ! This routine returns the result of a given timer. This can be
136 ! called instead of timer_print so that the calling routine can
137 ! print it in desired format.
138 !
139 !-----------------------------------------------------------------------
140 
141 !-----------------------------------------------------------------------
142 !
143 ! Input Variables:
144 !
145 !-----------------------------------------------------------------------
146 
147  integer (SCRIP_i4), intent(in) ::
148  & timer ! timer number
149 
150 !-----------------------------------------------------------------------
151 !
152 ! Output Variables:
153 !
154 !-----------------------------------------------------------------------
155 
156  real (SCRIP_r4) ::
157  & timer_get ! accumulated cputime in given timer
158 
159 !-----------------------------------------------------------------------
160 
161  if (status(timer) .eq. 'stopped') then
162  timer_get = cputime(timer)
163  else
164  call timer_stop(timer)
165  timer_get = cputime(timer)
166  call timer_start(timer)
167  endif
168 
169 !-----------------------------------------------------------------------
170 

References cputime, status, timer_start(), and timer_stop().

◆ timer_print()

subroutine scrip_timers::timer_print ( integer (scrip_i4), intent(in)  timer)

Definition at line 176 of file scrip_timers.f.

176 
177 !-----------------------------------------------------------------------
178 !
179 ! This routine prints the accumulated cpu time in given timer.
180 !
181 !-----------------------------------------------------------------------
182 
183 !-----------------------------------------------------------------------
184 !
185 ! Input Variables:
186 !
187 !-----------------------------------------------------------------------
188 
189  integer (SCRIP_i4), intent(in) ::
190  & timer ! timer number
191 
192 !-----------------------------------------------------------------------
193 
194  !---
195  !--- print the cputime accumulated for timer
196  !--- make sure timer is stopped
197  !---
198 
199  if (status(timer) .eq. 'stopped') then
200  write(*,"(' CPU time for timer',i3,':',1p,e16.8)")
201  & timer,cputime(timer)
202  else
203  call timer_stop(timer)
204  write(*,"(' CPU time for timer',i3,':',1p,e16.8)")
205  & timer,cputime(timer)
206  call timer_start(timer)
207  endif
208 
209 !-----------------------------------------------------------------------
210 

References cputime, status, timer_start(), and timer_stop().

Referenced by scrip_remap_conservative::remap_conserv().

◆ timer_start()

subroutine scrip_timers::timer_start ( integer (scrip_i4), intent(in)  timer)

Definition at line 216 of file scrip_timers.f.

216 
217 !-----------------------------------------------------------------------
218 !
219 ! This routine starts a given timer.
220 !
221 !-----------------------------------------------------------------------
222 
223 !-----------------------------------------------------------------------
224 !
225 ! Input Variables:
226 !
227 !-----------------------------------------------------------------------
228 
229  integer (SCRIP_i4), intent(in) ::
230  & timer ! timer number
231 
232 !-----------------------------------------------------------------------
233 
234  !---
235  !--- Start the timer and change timer status.
236  !---
237 
238  if (status(timer) .eq. 'stopped') then
239  call system_clock(count=cycles1(timer))
240  status(timer) = 'running'
241  endif
242 
243 !-----------------------------------------------------------------------
244 

References cycles1, and status.

Referenced by scrip_remap_conservative::remap_conserv(), timer_check(), timer_get(), and timer_print().

◆ timer_stop()

subroutine scrip_timers::timer_stop ( integer (scrip_i4), intent(in)  timer)

Definition at line 250 of file scrip_timers.f.

250 
251 !-----------------------------------------------------------------------
252 !
253 ! This routine stops a given timer.
254 !
255 !-----------------------------------------------------------------------
256 
257 !-----------------------------------------------------------------------
258 !
259 ! Input Variables:
260 !
261 !-----------------------------------------------------------------------
262 
263  integer (SCRIP_i4), intent(in) ::
264  & timer ! timer number
265 
266 !-----------------------------------------------------------------------
267 
268  if (status(timer) .eq. 'running') then
269 
270  !---
271  !--- Stop the desired timer.
272  !---
273 
274  call system_clock(count=cycles2(timer))
275 
276  !---
277  !--- check and correct for cycle wrapping
278  !---
279 
280  if (cycles2(timer) .ge. cycles1(timer)) then
281  cputime(timer) = cputime(timer) + clock_rate*
282  & (cycles2(timer) - cycles1(timer))
283  else
284  cputime(timer) = cputime(timer) + clock_rate*
285  & (cycles2(timer) - cycles1(timer) + cycles_max)
286  endif
287 
288  !---
289  !--- Change timer status.
290  !---
291 
292  status(timer)='stopped'
293 
294  endif
295 
296 !-----------------------------------------------------------------------
297 

References clock_rate, cputime, cycles1, cycles2, cycles_max, and status.

Referenced by scrip_remap_conservative::remap_conserv(), timer_check(), timer_get(), and timer_print().

◆ timers_init()

subroutine scrip_timers::timers_init

Definition at line 303 of file scrip_timers.f.

303 
304 !-----------------------------------------------------------------------
305 !
306 ! This routine initializes some machine parameters necessary for
307 ! computing cpu time from F90 intrinsics.
308 !
309 !-----------------------------------------------------------------------
310 
311  integer (SCRIP_i4) :: cycles ! count rate return by sys_clock
312 
313 !-----------------------------------------------------------------------
314 
315  !---
316  !--- Initialize timer arrays and clock_rate.
317  !---
318 
319  clock_rate = 0.0_scrip_r4
320  cycles1 = 0
321  cycles2 = 0
322  cputime = 0.0_scrip_r4
323  status = 'stopped'
324 
325  !---
326  !--- Call F90 intrinsic system_clock to determine clock rate
327  !--- and maximum cycles. If no clock available, print message.
328  !---
329 
330  call system_clock(count_rate=cycles, count_max=cycles_max)
331 
332  if (cycles /= 0) then
333  clock_rate = 1.0_scrip_r4/real(cycles)
334  else
335  clock_rate = 0.0_scrip_r4
336  print *, '--- No system clock available ---'
337  endif
338 
339 !-----------------------------------------------------------------------
340 

References clock_rate, cputime, cycles1, cycles2, cycles_max, and status.

Referenced by scrip_interface::scrip(), and scrip_interface::scrip_clear().

Variable Documentation

◆ clock_rate

real (scrip_r4), save scrip_timers::clock_rate

Definition at line 57 of file scrip_timers.f.

57  real (SCRIP_r4), save ::
58  & clock_rate ! clock_rate in seconds for each cycle

Referenced by timer_stop(), and timers_init().

◆ cputime

real (scrip_r4), dimension(max_timers), save scrip_timers::cputime

Definition at line 60 of file scrip_timers.f.

60  real (SCRIP_r4), dimension(max_timers), save ::
61  & cputime ! accumulated cpu time in each timer

Referenced by timer_clear(), timer_get(), timer_print(), timer_stop(), and timers_init().

◆ cycles1

integer (scrip_i4), dimension(max_timers), save scrip_timers::cycles1

Definition at line 53 of file scrip_timers.f.

53  integer (SCRIP_i4), dimension(max_timers), save ::
54  & cycles1, ! cycle number at start for each timer
55  & cycles2 ! cycle number at stop for each timer

Referenced by timer_start(), timer_stop(), and timers_init().

◆ cycles2

integer (scrip_i4), dimension(max_timers), save scrip_timers::cycles2

Definition at line 53 of file scrip_timers.f.

Referenced by timer_stop(), and timers_init().

◆ cycles_max

integer (scrip_i4), save scrip_timers::cycles_max

Definition at line 50 of file scrip_timers.f.

50  integer (SCRIP_i4), save ::
51  & cycles_max ! max value of clock allowed by system

Referenced by timer_stop(), and timers_init().

◆ max_timers

integer (scrip_i4), parameter scrip_timers::max_timers = 99

Definition at line 47 of file scrip_timers.f.

47  integer (SCRIP_i4), parameter ::
48  & max_timers = 99 ! max number of timers allowed

Referenced by scrip_interface::scrip().

◆ status

character (len=8), dimension(max_timers), save scrip_timers::status

Definition at line 63 of file scrip_timers.f.

63  character (len=8), dimension(max_timers), save ::
64  & status ! timer status string

Referenced by timer_check(), timer_get(), timer_print(), timer_start(), timer_stop(), and timers_init().

scrip_timers::timer_get
real(scrip_r4) function timer_get(timer)
Definition: scrip_timers.f:132
scrip_timers::cputime
real(scrip_r4), dimension(max_timers), save cputime
Definition: scrip_timers.f:60
scrip_timers::timer_start
subroutine timer_start(timer)
Definition: scrip_timers.f:216
scrip_timers::clock_rate
real(scrip_r4), save clock_rate
Definition: scrip_timers.f:57
scrip_timers::cycles_max
integer(scrip_i4), save cycles_max
Definition: scrip_timers.f:50
scrip_timers::status
character(len=8), dimension(max_timers), save status
Definition: scrip_timers.f:63
scrip_timers::cycles2
integer(scrip_i4), dimension(max_timers), save cycles2
Definition: scrip_timers.f:53
scrip_timers::cycles1
integer(scrip_i4), dimension(max_timers), save cycles1
Definition: scrip_timers.f:53
scrip_timers::timer_stop
subroutine timer_stop(timer)
Definition: scrip_timers.f:250