1 |
edhill |
1.13 |
C $Header: /u/u3/gcmpack/MITgcm/eesupp/src/timers.F,v 1.12 2001/11/08 23:40:52 heimbach Exp $ |
2 |
|
|
C $Name: $ |
3 |
adcroft |
1.1 |
|
4 |
|
|
#include "CPP_EEOPTIONS.h" |
5 |
|
|
|
6 |
|
|
C-- File utils.F: General purpose support routines |
7 |
|
|
C-- Contents |
8 |
|
|
C-- TIMER_INDEX - Returns index associated with timer name. |
9 |
|
|
C-- M TIMER_CONTROL - Implements timer functions for given machine. |
10 |
|
|
C-- TIMER_PRINT - Print CPU timer statitics. |
11 |
|
|
C-- TIMER_PRINTALL - Prints all CPU timers statistics. |
12 |
|
|
C-- TIMER_START - Starts CPU timer for code section. |
13 |
|
|
C-- TIMER_STOP - Stop CPU tier for code section. |
14 |
|
|
C-- Routines marked "M" contain specific machine dependent code. |
15 |
|
|
C-- Routines marked "U" contain UNIX OS calls. |
16 |
|
|
|
17 |
heimbach |
1.12 |
CGG Modified following A. Biastoch for use with SP3. Is backwards |
18 |
|
|
CGG compatible. G. Gebbie, gebbie@mit.edu, 20 Oct 2001, Scripps. |
19 |
|
|
|
20 |
cnh |
1.10 |
CBOP |
21 |
|
|
C !ROUTINE: TIMER_INDEX |
22 |
|
|
|
23 |
|
|
C !INTERFACE: |
24 |
adcroft |
1.1 |
INTEGER FUNCTION TIMER_INDEX ( |
25 |
|
|
I name,timerNames,maxTimers,nTimers ) |
26 |
adcroft |
1.5 |
IMPLICIT NONE |
27 |
cnh |
1.10 |
|
28 |
|
|
C !DESCRIPTION: |
29 |
|
|
C *==========================================================* |
30 |
|
|
C | FUNCTION TIMER_INDEX |
31 |
|
|
C | o Timing support routine. |
32 |
|
|
C *==========================================================* |
33 |
|
|
C | Return index in timer data structure of timer named |
34 |
|
|
C | by the function argument "name". |
35 |
|
|
C *==========================================================* |
36 |
|
|
|
37 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
38 |
|
|
C == Routine arguements == |
39 |
|
|
C maxTimers :: Total number of timers allowed |
40 |
|
|
C nTimers :: Current number of timers |
41 |
|
|
C name :: Name of timer to find |
42 |
|
|
C timerNames :: List of valid timer names |
43 |
adcroft |
1.1 |
INTEGER maxTimers |
44 |
|
|
INTEGER nTimers |
45 |
|
|
CHARACTER*(*) name |
46 |
|
|
CHARACTER*(*) timerNames(maxTimers) |
47 |
cnh |
1.10 |
|
48 |
|
|
C !LOCAL VARIABLES: |
49 |
|
|
C == Local variables == |
50 |
|
|
C I :: Index variable |
51 |
adcroft |
1.1 |
INTEGER I |
52 |
cnh |
1.10 |
CEOP |
53 |
adcroft |
1.1 |
C |
54 |
|
|
TIMER_INDEX = 0 |
55 |
|
|
IF ( name .EQ. ' ' ) THEN |
56 |
|
|
TIMER_INDEX = -1 |
57 |
|
|
ELSE |
58 |
|
|
DO 10 I = 1, nTimers |
59 |
|
|
IF ( name .NE. timerNames(I) ) GOTO 10 |
60 |
|
|
TIMER_INDEX = I |
61 |
|
|
GOTO 11 |
62 |
|
|
10 CONTINUE |
63 |
|
|
11 CONTINUE |
64 |
|
|
ENDIF |
65 |
|
|
RETURN |
66 |
|
|
END |
67 |
|
|
|
68 |
cnh |
1.10 |
CBOP |
69 |
|
|
C !ROUTINE: TIMER_CONTROL |
70 |
|
|
|
71 |
|
|
C !INTERFACE: |
72 |
adcroft |
1.1 |
SUBROUTINE TIMER_CONTROL ( name , action , callProc , myThreadId ) |
73 |
cnh |
1.10 |
IMPLICIT NONE |
74 |
|
|
|
75 |
|
|
C !DESCRIPTION: |
76 |
|
|
C *==========================================================* |
77 |
adcroft |
1.1 |
C | SUBROUTINE TIMER_CONTROL | |
78 |
|
|
C | o Timing routine. | |
79 |
cnh |
1.10 |
C *==========================================================* |
80 |
adcroft |
1.1 |
C | User callable interface to timing routines. Timers are | |
81 |
|
|
C | created, stopped, started and queried only through this | |
82 |
|
|
C | rtouine. | |
83 |
cnh |
1.10 |
C *==========================================================* |
84 |
|
|
|
85 |
|
|
C !USES: |
86 |
adcroft |
1.1 |
#include "SIZE.h" |
87 |
|
|
#include "EEPARAMS.h" |
88 |
|
|
#include "EESUPPORT.h" |
89 |
|
|
INTEGER TIMER_INDEX |
90 |
|
|
INTEGER IFNBLNK |
91 |
|
|
INTEGER ILNBLNK |
92 |
|
|
EXTERNAL TIMER_INDEX |
93 |
|
|
EXTERNAL IFNBLNK |
94 |
|
|
EXTERNAL ILNBLNK |
95 |
cnh |
1.10 |
|
96 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
97 |
|
|
C name :: name of the timer |
98 |
|
|
C action :: operation to perform with this timer |
99 |
|
|
C callProc :: procedure calling this routine |
100 |
|
|
C myThreadId :: instance number of this thread |
101 |
|
|
CHARACTER*(*) name |
102 |
|
|
CHARACTER*(*) action |
103 |
|
|
CHARACTER*(*) callProc |
104 |
|
|
INTEGER myThreadId |
105 |
adcroft |
1.1 |
C |
106 |
cnh |
1.10 |
C !LOCAL VARIABLES: |
107 |
|
|
C maxTimers :: Total numer of timer allowed |
108 |
|
|
C maxString :: Max length of a timer name |
109 |
adcroft |
1.1 |
INTEGER maxTimers |
110 |
|
|
INTEGER maxString |
111 |
|
|
PARAMETER ( maxTimers = 40 ) |
112 |
|
|
PARAMETER ( maxString = 80 ) |
113 |
cnh |
1.10 |
C timerStarts :: Timer counters for each timer and each thread |
114 |
|
|
C timerStops |
115 |
|
|
C timerUser |
116 |
|
|
C timerWall |
117 |
|
|
C timerSys |
118 |
|
|
C timerT0User |
119 |
|
|
C timerT0Wall |
120 |
|
|
C timerT0Sys |
121 |
|
|
C timerStatus :: START/STOP/RUNNING Status of the timer |
122 |
|
|
C timerNameLen :: Length of timer name |
123 |
|
|
C timerNames :: Table of timer names |
124 |
|
|
C nTimers :: Number of active timers |
125 |
adcroft |
1.1 |
INTEGER timerStarts( maxTimers , MAX_NO_THREADS) |
126 |
|
|
SAVE timerStarts |
127 |
|
|
INTEGER timerStops ( maxTimers , MAX_NO_THREADS) |
128 |
|
|
SAVE timerStops |
129 |
|
|
Real*8 timerUser ( maxTimers , MAX_NO_THREADS) |
130 |
|
|
SAVE timerUser |
131 |
|
|
Real*8 timerWall ( maxTimers , MAX_NO_THREADS) |
132 |
|
|
SAVE timerWall |
133 |
|
|
Real*8 timerSys ( maxTimers , MAX_NO_THREADS) |
134 |
|
|
SAVE timerSys |
135 |
|
|
Real*8 timerT0User( maxTimers , MAX_NO_THREADS) |
136 |
|
|
SAVE timerT0User |
137 |
|
|
Real*8 timerT0Wall( maxTimers , MAX_NO_THREADS) |
138 |
|
|
SAVE timerT0Wall |
139 |
|
|
Real*8 timerT0Sys ( maxTimers , MAX_NO_THREADS) |
140 |
|
|
SAVE timerT0Sys |
141 |
|
|
INTEGER timerStatus( maxTimers , MAX_NO_THREADS) |
142 |
|
|
SAVE timerStatus |
143 |
|
|
INTEGER timerNameLen( maxTimers , MAX_NO_THREADS) |
144 |
|
|
SAVE timerNameLen |
145 |
|
|
CHARACTER*(maxString) timerNames( maxTimers , MAX_NO_THREADS) |
146 |
|
|
SAVE timerNames |
147 |
|
|
INTEGER nTimers(MAX_NO_THREADS) |
148 |
|
|
CHARACTER*(maxString) tmpName |
149 |
|
|
CHARACTER*(maxString) tmpAction |
150 |
|
|
INTEGER iTimer |
151 |
|
|
INTEGER ISTART |
152 |
|
|
INTEGER IEND |
153 |
|
|
INTEGER STOPPED |
154 |
|
|
PARAMETER ( STOPPED = 0 ) |
155 |
|
|
INTEGER RUNNING |
156 |
|
|
PARAMETER ( RUNNING = 1 ) |
157 |
|
|
CHARACTER*(*) STOP |
158 |
|
|
PARAMETER ( STOP = 'STOP' ) |
159 |
|
|
CHARACTER*(*) START |
160 |
|
|
PARAMETER ( START = 'START' ) |
161 |
|
|
CHARACTER*(*) PRINT |
162 |
|
|
PARAMETER ( PRINT = 'PRINT' ) |
163 |
|
|
CHARACTER*(*) PRINTALL |
164 |
|
|
PARAMETER ( PRINTALL = 'PRINTALL' ) |
165 |
|
|
INTEGER I |
166 |
|
|
Real*8 userTime |
167 |
|
|
Real*8 systemTime |
168 |
|
|
Real*8 wallClockTime |
169 |
|
|
CHARACTER*(MAX_LEN_MBUF) msgBuffer |
170 |
|
|
DATA nTimers /MAX_NO_THREADS*0/ |
171 |
|
|
SAVE nTimers |
172 |
cnh |
1.10 |
CEOP |
173 |
adcroft |
1.1 |
C |
174 |
|
|
ISTART = IFNBLNK(name) |
175 |
|
|
IEND = ILNBLNK(name) |
176 |
|
|
IF ( IEND - ISTART + 1 .GT. maxString ) GOTO 901 |
177 |
|
|
IF ( ISTART .NE. 0 ) THEN |
178 |
|
|
tmpName = name(ISTART:IEND) |
179 |
|
|
CALL UCASE( tmpName ) |
180 |
|
|
ELSE |
181 |
|
|
tmpName = ' ' |
182 |
|
|
ENDIF |
183 |
|
|
ISTART = IFNBLNK(action) |
184 |
|
|
IEND = ILNBLNK(action) |
185 |
|
|
IF ( ISTART .EQ. 0 ) GOTO 902 |
186 |
|
|
IF ( IEND - ISTART + 1 .GT. maxString ) GOTO 903 |
187 |
|
|
tmpAction = action(ISTART:IEND) |
188 |
|
|
CALL UCASE( tmpAction ) |
189 |
|
|
C |
190 |
cnh |
1.4 |
iTimer=TIMER_INDEX(tmpName,timerNames(1,myThreadId), |
191 |
|
|
& maxTimers,nTimers(myThreadId)) |
192 |
adcroft |
1.1 |
C |
193 |
|
|
IF ( tmpAction .EQ. START ) THEN |
194 |
|
|
IF ( iTimer .EQ. 0 ) THEN |
195 |
|
|
IF ( nTimers(myThreadId) .EQ. maxTimers ) GOTO 904 |
196 |
|
|
nTimers(myThreadId) = nTimers(myThreadId) + 1 |
197 |
|
|
iTimer = nTimers(myThreadId) |
198 |
|
|
timerNames(iTimer,myThreadId) = tmpName |
199 |
cnh |
1.4 |
timerNameLen(iTimer,myThreadId) = |
200 |
|
|
& ILNBLNK(tmpName)-IFNBLNK(tmpName)+1 |
201 |
adcroft |
1.1 |
timerUser(iTimer,myThreadId) = 0. |
202 |
|
|
timerSys (iTimer,myThreadId) = 0. |
203 |
|
|
timerWall(iTimer,myThreadId) = 0. |
204 |
|
|
timerStarts(iTimer,myThreadId) = 0 |
205 |
|
|
timerStops (iTimer,myThreadId) = 0 |
206 |
|
|
timerStatus(iTimer,myThreadId) = STOPPED |
207 |
|
|
ENDIF |
208 |
|
|
IF ( timerStatus(iTimer,myThreadId) .NE. RUNNING ) THEN |
209 |
|
|
CALL TIMER_GET_TIME( userTime, systemTime, wallClockTime ) |
210 |
|
|
timerT0User(iTimer,myThreadId) = userTime |
211 |
|
|
timerT0Sys(iTimer,myThreadId) = systemTime |
212 |
|
|
timerT0Wall(iTimer,myThreadId) = wallClockTime |
213 |
|
|
timerStatus(iTimer,myThreadId) = RUNNING |
214 |
cnh |
1.4 |
timerStarts(iTimer,myThreadId) = |
215 |
|
|
& timerStarts(iTimer,myThreadId)+1 |
216 |
adcroft |
1.1 |
ENDIF |
217 |
|
|
ELSEIF ( tmpAction .EQ. STOP ) THEN |
218 |
|
|
IF ( iTimer .EQ. 0 ) GOTO 905 |
219 |
|
|
IF ( timerStatus(iTimer,myThreadId) .EQ. RUNNING ) THEN |
220 |
|
|
CALL TIMER_GET_TIME( userTime, systemTime, wallClockTime ) |
221 |
cnh |
1.4 |
timerUser(iTimer,myThreadId) = |
222 |
|
|
& timerUser(iTimer,myThreadId) + |
223 |
adcroft |
1.1 |
& userTime - |
224 |
|
|
& timerT0User(iTimer,myThreadId) |
225 |
cnh |
1.4 |
timerSys (iTimer,myThreadId) = |
226 |
|
|
& timerSys(iTimer,myThreadId) + |
227 |
adcroft |
1.1 |
& systemTime - |
228 |
|
|
& timerT0Sys(iTimer,myThreadId) |
229 |
cnh |
1.4 |
timerWall(iTimer,myThreadId) = |
230 |
|
|
& timerWall(iTimer,myThreadId) + |
231 |
adcroft |
1.1 |
& wallClockTime - |
232 |
|
|
& timerT0Wall(iTimer,myThreadId) |
233 |
|
|
timerStatus(iTimer,myThreadId) = STOPPED |
234 |
cnh |
1.4 |
timerStops (iTimer,myThreadId) = |
235 |
|
|
& timerStops (iTimer,myThreadId)+1 |
236 |
adcroft |
1.1 |
ENDIF |
237 |
|
|
ELSEIF ( tmpAction .EQ. PRINT ) THEN |
238 |
|
|
IF ( iTimer .EQ. 0 ) GOTO 905 |
239 |
|
|
WRITE(msgBuffer,*) |
240 |
|
|
& ' Seconds in section "', |
241 |
cnh |
1.4 |
& timerNames(iTimer,myThreadId)(1:timerNameLen(iTimer,myThreadId)) |
242 |
|
|
& ,'":' |
243 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
244 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
245 |
|
|
WRITE(msgBuffer,*) ' User time:', |
246 |
|
|
& timerUser(iTimer,myThreadId) |
247 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
248 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
249 |
|
|
WRITE(msgBuffer,*) ' System time:', |
250 |
|
|
& timerSys(iTimer,myThreadId) |
251 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
252 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
253 |
|
|
WRITE(msgBuffer,*) ' Wall clock time:', |
254 |
|
|
& timerWall(iTimer,myThreadId) |
255 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
256 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
257 |
|
|
WRITE(msgBuffer,*) ' No. starts:', |
258 |
|
|
& timerStarts(iTimer,myThreadId) |
259 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
260 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
261 |
|
|
WRITE(msgBuffer,*) ' No. stops:', |
262 |
|
|
& timerStops(iTimer,myThreadId) |
263 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
264 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
265 |
adcroft |
1.1 |
ELSEIF ( tmpAction .EQ. PRINTALL ) THEN |
266 |
|
|
DO 10 I = 1, nTimers(myThreadId) |
267 |
|
|
WRITE(msgBuffer,*) ' Seconds in section "', |
268 |
cnh |
1.4 |
& timerNames(I,myThreadId)(1:timerNameLen(I,myThreadId)) |
269 |
|
|
& ,'":' |
270 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
271 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
272 |
|
|
WRITE(msgBuffer,*) ' User time:', |
273 |
|
|
& timerUser(I,myThreadId) |
274 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
275 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
276 |
|
|
WRITE(msgBuffer,*) ' System time:', |
277 |
|
|
& timerSys(I,myThreadId) |
278 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
279 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
280 |
|
|
WRITE(msgBuffer,*) ' Wall clock time:', |
281 |
|
|
& timerWall(I,myThreadId) |
282 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
283 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
284 |
|
|
WRITE(msgBuffer,*) ' No. starts:', |
285 |
|
|
& timerStarts(I,myThreadId) |
286 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
287 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
288 |
|
|
WRITE(msgBuffer,*) ' No. stops:', |
289 |
|
|
& timerStops(I,myThreadId) |
290 |
|
|
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
291 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
292 |
adcroft |
1.1 |
10 CONTINUE |
293 |
|
|
ELSE |
294 |
|
|
GOTO 903 |
295 |
|
|
ENDIF |
296 |
|
|
C |
297 |
|
|
1000 CONTINUE |
298 |
|
|
C |
299 |
|
|
RETURN |
300 |
|
|
901 CONTINUE |
301 |
|
|
WRITE(msgBuffer,'(A)') |
302 |
|
|
&' ' |
303 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
304 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
305 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
306 |
|
|
&'*** WARNING WARNING WARNING WARNING WARNING WARNING ***' |
307 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
308 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
309 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
310 |
|
|
&'procedure: "',callProc,'".' |
311 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
312 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
313 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
314 |
|
|
&'Timer name "',name(ISTART:IEND),'" is invalid.' |
315 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
316 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
317 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
318 |
|
|
&' Names must have fewer than',maxString+1,' characters.' |
319 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
320 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
321 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
322 |
|
|
&'*******************************************************' |
323 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
324 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
325 |
adcroft |
1.1 |
GOTO 1000 |
326 |
|
|
902 CONTINUE |
327 |
|
|
WRITE(msgBuffer,*) |
328 |
|
|
&' ' |
329 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
330 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
331 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
332 |
|
|
&'*** WARNING WARNING WARNING WARNING WARNING WARNING ***' |
333 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
334 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
335 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
336 |
|
|
&'procedure: "',callProc,'".' |
337 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
338 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
339 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
340 |
|
|
&' No timer action specified.' |
341 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
342 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
343 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
344 |
|
|
&' Valid actions are:' |
345 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
346 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
347 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
348 |
|
|
&' "START", "STOP", "PRINT" and "PRINTALL".' |
349 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
350 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
351 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
352 |
|
|
&'*******************************************************' |
353 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
354 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
355 |
adcroft |
1.1 |
GOTO 1000 |
356 |
|
|
903 CONTINUE |
357 |
|
|
WRITE(msgBuffer,*) |
358 |
|
|
&' ' |
359 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
360 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
361 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
362 |
|
|
&'*** WARNING WARNING WARNING WARNING WARNING WARNING ***' |
363 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
364 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
365 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
366 |
|
|
&'procedure: "',callProc,'".' |
367 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
368 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
369 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
370 |
|
|
&'Timer action"',name(ISTART:IEND),'" is invalid.' |
371 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
372 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
373 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
374 |
|
|
&' Valid actions are:' |
375 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
376 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
377 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
378 |
|
|
&' "START", "STOP", "PRINT" and "PRINTALL".' |
379 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
380 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
381 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
382 |
|
|
&'*******************************************************' |
383 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
384 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
385 |
adcroft |
1.1 |
GOTO 1000 |
386 |
|
|
904 CONTINUE |
387 |
|
|
WRITE(msgBuffer,*) |
388 |
|
|
&' ' |
389 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
390 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
391 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
392 |
|
|
&'*** WARNING WARNING WARNING WARNING WARNING WARNING ***' |
393 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
394 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
395 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
396 |
|
|
&'procedure: "',callProc,'".' |
397 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
398 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
399 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
400 |
|
|
&'Timer "',name(ISTART:IEND),'" cannot be created.' |
401 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
402 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
403 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
404 |
|
|
&' Only ',maxTimers,' timers are allowed.' |
405 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
406 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
407 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
408 |
|
|
&'*******************************************************' |
409 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
410 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
411 |
adcroft |
1.1 |
GOTO 1000 |
412 |
|
|
905 CONTINUE |
413 |
|
|
WRITE(msgBuffer,*) |
414 |
|
|
&' ' |
415 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
416 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
417 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
418 |
|
|
&'*** WARNING WARNING WARNING WARNING WARNING WARNING ***' |
419 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
420 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
421 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
422 |
|
|
&'procedure: "',callProc,'".' |
423 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
424 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
425 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
426 |
|
|
&'Timer name is blank.' |
427 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
428 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
429 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
430 |
|
|
&' A name must be used with "START", "STOP" or "PRINT".' |
431 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
432 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
433 |
adcroft |
1.1 |
WRITE(msgBuffer,*) |
434 |
|
|
&'*******************************************************' |
435 |
cnh |
1.4 |
CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit, |
436 |
|
|
& SQUEEZE_RIGHT,myThreadId) |
437 |
adcroft |
1.1 |
GOTO 1000 |
438 |
|
|
END |
439 |
|
|
|
440 |
cnh |
1.10 |
CBOP |
441 |
|
|
C !ROUTINE: TIMER_GET_TIME |
442 |
|
|
|
443 |
|
|
C !INTERFACE: |
444 |
adcroft |
1.1 |
SUBROUTINE TIMER_GET_TIME( |
445 |
|
|
O userTime, |
446 |
|
|
O systemTime, |
447 |
|
|
O wallClockTime ) |
448 |
adcroft |
1.5 |
IMPLICIT NONE |
449 |
cnh |
1.10 |
|
450 |
|
|
C !DESCRIPTION: |
451 |
|
|
C *==========================================================* |
452 |
|
|
C | SUBROUTINE TIMER_GET_TIME |
453 |
|
|
C | o Query system timer routines. |
454 |
|
|
C *==========================================================* |
455 |
|
|
C | Routine returns total elapsed time for program so far. |
456 |
|
|
C | Three times are returned that conventionally are used as |
457 |
|
|
C | user time, system time and wall-clock time. Not all these |
458 |
|
|
C | numbers are available on all machines. |
459 |
|
|
C *==========================================================* |
460 |
|
|
|
461 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
462 |
|
|
C userTime :: User time returned |
463 |
|
|
C systemTime :: System time returned |
464 |
|
|
C wallClockTime :: Wall clock time returned |
465 |
adcroft |
1.1 |
Real*8 userTime |
466 |
|
|
Real*8 systemTime |
467 |
|
|
Real*8 wallClockTime |
468 |
cnh |
1.10 |
|
469 |
|
|
C !USES: |
470 |
edhill |
1.13 |
#ifndef HAVE_FDATE |
471 |
heimbach |
1.12 |
Real*8 system_time, user_time, timenow |
472 |
edhill |
1.13 |
#else |
473 |
cnh |
1.10 |
Real*4 ETIME |
474 |
adcroft |
1.1 |
EXTERNAL ETIME |
475 |
heimbach |
1.8 |
#endif |
476 |
cnh |
1.10 |
|
477 |
|
|
C !LOCAL VARIABLES: |
478 |
|
|
C ACTUAL, TARRAY, :: Temps. to hold times |
479 |
|
|
C wTime |
480 |
|
|
Real*4 ACTUAL, TARRAY(2) |
481 |
adcroft |
1.1 |
Real*8 wtime |
482 |
cnh |
1.10 |
CEOP |
483 |
|
|
|
484 |
cnh |
1.4 |
C Real*8 MPI_Wtime |
485 |
|
|
C EXTERNAL MPI_Wtime |
486 |
adcroft |
1.1 |
|
487 |
heimbach |
1.12 |
#if (defined (TARGET_PWR3)) |
488 |
|
|
userTime = user_time() |
489 |
|
|
systemTime = system_time() |
490 |
|
|
wallClockTime = timenow() |
491 |
|
|
#elif (defined (TARGET_T3E) || defined (TARGET_CRAY_VECTOR)) |
492 |
|
|
userTime = 0. |
493 |
|
|
systemTime = 0. |
494 |
|
|
wallClockTime = 0. |
495 |
adcroft |
1.6 |
#else |
496 |
adcroft |
1.1 |
ACTUAL = ETIME(TARRAY) |
497 |
|
|
userTime = TARRAY(1) |
498 |
|
|
systemTime = TARRAY(2) |
499 |
cnh |
1.3 |
CALL CLOC(wTime) |
500 |
|
|
wallClockTime = wtime |
501 |
adcroft |
1.6 |
#endif |
502 |
cnh |
1.3 |
|
503 |
adcroft |
1.1 |
#ifdef ALLOW_USE_MPI |
504 |
cnh |
1.3 |
C wtime = MPI_Wtime() |
505 |
|
|
C wallClockTime = wtime |
506 |
adcroft |
1.1 |
#endif /* ALLOW_USE_MPI */ |
507 |
|
|
#ifndef ALLOW_USE_MPI |
508 |
cnh |
1.3 |
C wallClockTime = 0. |
509 |
adcroft |
1.1 |
#endif |
510 |
|
|
|
511 |
|
|
RETURN |
512 |
|
|
END |
513 |
|
|
|
514 |
cnh |
1.10 |
CBOP |
515 |
|
|
|
516 |
|
|
C !ROUTINE: TIMER_PRINTALL |
517 |
|
|
|
518 |
|
|
C !INTERFACE: |
519 |
adcroft |
1.1 |
SUBROUTINE TIMER_PRINTALL( myThreadId ) |
520 |
adcroft |
1.5 |
IMPLICIT NONE |
521 |
cnh |
1.10 |
|
522 |
|
|
C !DESCRIPTION: |
523 |
|
|
C *==========================================================* |
524 |
|
|
C | SUBROUTINE TIMER_PRINTALL |
525 |
|
|
C | o Print timer information |
526 |
|
|
C *==========================================================* |
527 |
|
|
C | Request print out of table of timing from all timers. |
528 |
|
|
C *==========================================================* |
529 |
|
|
|
530 |
|
|
C !INPUT PARAMETERS: |
531 |
|
|
C myThreadId :: This threads number |
532 |
adcroft |
1.1 |
INTEGER myThreadId |
533 |
cnh |
1.10 |
CEOP |
534 |
|
|
|
535 |
cnh |
1.4 |
CALL TIMER_CONTROL( ' ', 'PRINTALL', 'TIMER_PRINTALL' , |
536 |
|
|
& myThreadId ) |
537 |
adcroft |
1.1 |
C |
538 |
|
|
RETURN |
539 |
|
|
END |
540 |
cnh |
1.10 |
|
541 |
|
|
CBOP |
542 |
|
|
C !ROUTINE: TIMER_START |
543 |
|
|
|
544 |
|
|
C !INTERFACE: |
545 |
adcroft |
1.1 |
SUBROUTINE TIMER_START ( string , myThreadId ) |
546 |
adcroft |
1.5 |
IMPLICIT NONE |
547 |
cnh |
1.10 |
|
548 |
|
|
C !DESCRIPTION: |
549 |
|
|
C Start timer named "string". |
550 |
|
|
|
551 |
|
|
C !INPUT PARAMETERS: |
552 |
|
|
C string :: Name of timer |
553 |
|
|
C myThreadId :: My thread number |
554 |
adcroft |
1.1 |
CHARACTER*(*) string |
555 |
|
|
INTEGER myThreadId |
556 |
cnh |
1.10 |
CEOP |
557 |
adcroft |
1.1 |
C |
558 |
|
|
CALL TIMER_CONTROL( string, 'START', 'TIMER_START' , myThreadId) |
559 |
|
|
C |
560 |
|
|
RETURN |
561 |
|
|
END |
562 |
cnh |
1.10 |
CBOP |
563 |
|
|
C !ROUTINE: TIMER_STOP |
564 |
|
|
|
565 |
|
|
C !INTERFACE: |
566 |
adcroft |
1.1 |
SUBROUTINE TIMER_STOP ( string , myThreadId) |
567 |
adcroft |
1.5 |
IMPLICIT NONE |
568 |
cnh |
1.10 |
|
569 |
|
|
C !DESCRIPTION: |
570 |
|
|
C Stop timer named "string". |
571 |
|
|
|
572 |
|
|
C !INPUT PARAMETERS: |
573 |
|
|
C string :: Name of timer |
574 |
|
|
C myThreadId :: My thread number |
575 |
adcroft |
1.1 |
CHARACTER*(*) string |
576 |
|
|
INTEGER myThreadId |
577 |
cnh |
1.10 |
CEOP |
578 |
adcroft |
1.1 |
C |
579 |
|
|
CALL TIMER_CONTROL( string, 'STOP', 'TIMER_STOP' , myThreadId ) |
580 |
|
|
C |
581 |
|
|
RETURN |
582 |
|
|
END |
583 |
|
|
C*********************************************************************** |