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