/[MITgcm]/MITgcm/eesupp/src/timers.F
ViewVC logotype

Diff of /MITgcm/eesupp/src/timers.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4 by cnh, Wed Oct 28 03:11:35 1998 UTC revision 1.11.4.1 by heimbach, Wed Feb 6 15:48:06 2002 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4  #include "CPP_EEOPTIONS.h"  #include "CPP_EEOPTIONS.h"
5    
# Line 13  C--   TIMER_STOP      - Stop CPU tier fo Line 14  C--   TIMER_STOP      - Stop CPU tier fo
14  C--   Routines marked "M" contain specific machine dependent code.  C--   Routines marked "M" contain specific machine dependent code.
15  C--   Routines marked "U" contain UNIX OS calls.  C--   Routines marked "U" contain UNIX OS calls.
16    
17  CStartOfInterface  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    CBOP
21    C     !ROUTINE: TIMER_INDEX
22    
23    C     !INTERFACE:
24        INTEGER FUNCTION TIMER_INDEX (        INTEGER FUNCTION TIMER_INDEX (
25       I        name,timerNames,maxTimers,nTimers )       I        name,timerNames,maxTimers,nTimers )
26  C     /==========================================================\        IMPLICIT NONE
27  C     | FUNCTION TIMER_INDEX                                     |  
28  C     | o Timing support routine.                                |  C     !DESCRIPTION:
29  C     |==========================================================|  C     *==========================================================*
30  C     | Return index in timer data structure of timer named      |  C     | FUNCTION TIMER_INDEX                                      
31  C     | by the function argument "name".                         |  C     | o Timing support routine.                                
32  C     \==========================================================/  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        INTEGER maxTimers        INTEGER maxTimers
44        INTEGER nTimers        INTEGER nTimers
45        CHARACTER*(*) name        CHARACTER*(*) name
46        CHARACTER*(*) timerNames(maxTimers)        CHARACTER*(*) timerNames(maxTimers)
47  CEndOfInterface  
48    C     !LOCAL VARIABLES:
49    C     == Local variables ==
50    C     I :: Index variable
51        INTEGER I        INTEGER I
52    CEOP
53  C  C
54        TIMER_INDEX = 0        TIMER_INDEX = 0
55        IF ( name .EQ. ' ' ) THEN        IF ( name .EQ. ' ' ) THEN
# Line 44  C Line 65  C
65        RETURN        RETURN
66        END        END
67    
68  CStartOfInterface  CBOP
69    C     !ROUTINE: TIMER_CONTROL
70    
71    C     !INTERFACE:
72        SUBROUTINE TIMER_CONTROL ( name , action , callProc , myThreadId )        SUBROUTINE TIMER_CONTROL ( name , action , callProc , myThreadId )
73  C     /==========================================================\        IMPLICIT NONE
74    
75    C     !DESCRIPTION:
76    C     *==========================================================*
77  C     | SUBROUTINE TIMER_CONTROL                                 |  C     | SUBROUTINE TIMER_CONTROL                                 |
78  C     | o Timing routine.                                        |  C     | o Timing routine.                                        |
79  C     |==========================================================|  C     *==========================================================*
80  C     | User callable interface to timing routines. Timers are   |  C     | User callable interface to timing routines. Timers are   |
81  C     | created, stopped, started and queried only through this  |  C     | created, stopped, started and queried only through this  |
82  C     | rtouine.                                                 |  C     | rtouine.                                                 |
83  C     \==========================================================/  C     *==========================================================*
84    
85    C     !USES:
86  #include "SIZE.h"  #include "SIZE.h"
87  #include "EEPARAMS.h"  #include "EEPARAMS.h"
88  #include "EESUPPORT.h"  #include "EESUPPORT.h"
       CHARACTER*(*) name  
       CHARACTER*(*) action  
       CHARACTER*(*) callProc  
       INTEGER myThreadId  
 CEndOfInterface  
 C  
89        INTEGER  TIMER_INDEX        INTEGER  TIMER_INDEX
90        INTEGER  IFNBLNK        INTEGER  IFNBLNK
91        INTEGER  ILNBLNK        INTEGER  ILNBLNK
92        EXTERNAL TIMER_INDEX        EXTERNAL TIMER_INDEX
93        EXTERNAL IFNBLNK        EXTERNAL IFNBLNK
94        EXTERNAL ILNBLNK        EXTERNAL ILNBLNK
95    
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  C  C
106    C     !LOCAL VARIABLES:
107    C     maxTimers :: Total numer of timer allowed
108    C     maxString :: Max length of a timer name
109        INTEGER maxTimers        INTEGER maxTimers
110        INTEGER maxString        INTEGER maxString
111        PARAMETER ( maxTimers = 40 )        PARAMETER ( maxTimers = 40 )
112        PARAMETER ( maxString = 80 )        PARAMETER ( maxString = 80 )
113  C  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        INTEGER timerStarts( maxTimers , MAX_NO_THREADS)        INTEGER timerStarts( maxTimers , MAX_NO_THREADS)
126        SAVE    timerStarts        SAVE    timerStarts
127        INTEGER timerStops ( maxTimers , MAX_NO_THREADS)        INTEGER timerStops ( maxTimers , MAX_NO_THREADS)
# Line 91  C Line 138  C
138        SAVE timerT0Wall        SAVE timerT0Wall
139        Real*8 timerT0Sys ( maxTimers , MAX_NO_THREADS)        Real*8 timerT0Sys ( maxTimers , MAX_NO_THREADS)
140        SAVE timerT0Sys        SAVE timerT0Sys
 C     ===============================================================  
 C  
141        INTEGER timerStatus( maxTimers , MAX_NO_THREADS)        INTEGER timerStatus( maxTimers , MAX_NO_THREADS)
142        SAVE    timerStatus        SAVE    timerStatus
143        INTEGER timerNameLen( maxTimers , MAX_NO_THREADS)        INTEGER timerNameLen( maxTimers , MAX_NO_THREADS)
144        SAVE    timerNameLen        SAVE    timerNameLen
145        CHARACTER*(maxString) timerNames( maxTimers , MAX_NO_THREADS)        CHARACTER*(maxString) timerNames( maxTimers , MAX_NO_THREADS)
146        SAVE                  timerNames        SAVE                  timerNames
       CHARACTER*(maxString) timerAction  
147        INTEGER nTimers(MAX_NO_THREADS)        INTEGER nTimers(MAX_NO_THREADS)
148        CHARACTER*(maxString) tmpName        CHARACTER*(maxString) tmpName
149        CHARACTER*(maxString) tmpAction        CHARACTER*(maxString) tmpAction
# Line 123  C Line 167  C
167        Real*8 systemTime        Real*8 systemTime
168        Real*8 wallClockTime        Real*8 wallClockTime
169        CHARACTER*(MAX_LEN_MBUF) msgBuffer        CHARACTER*(MAX_LEN_MBUF) msgBuffer
 C  
170        DATA nTimers  /MAX_NO_THREADS*0/        DATA nTimers  /MAX_NO_THREADS*0/
171        SAVE nTimers        SAVE nTimers
172    CEOP
173  C  C
174        ISTART = IFNBLNK(name)        ISTART = IFNBLNK(name)
175        IEND   = ILNBLNK(name)        IEND   = ILNBLNK(name)
# Line 393  C Line 437  C
437        GOTO 1000        GOTO 1000
438        END        END
439    
440  CStartOfInterface  CBOP
441    C     !ROUTINE: TIMER_GET_TIME
442    
443    C     !INTERFACE:
444        SUBROUTINE TIMER_GET_TIME(        SUBROUTINE TIMER_GET_TIME(
445       O                           userTime,       O                           userTime,
446       O                           systemTime,       O                           systemTime,
447       O                           wallClockTime )       O                           wallClockTime )
448  C     /==========================================================\        IMPLICIT NONE
449  C     | SUBROUTINE TIMER_GET_TIME                                |  
450  C     | o Query system timer routines.                           |  C     !DESCRIPTION:
451  C     |==========================================================|  C     *==========================================================*
452  C     | Routine returns total elapsed time for program so far.   |  C     | SUBROUTINE TIMER_GET_TIME                                
453  C     | Three times are returned that conventionally are used as |  C     | o Query system timer routines.                            
454  C     | user time, system time and wall-clock time. Not all these|  C     *==========================================================*
455  C     | numbers are available on all machines.                   |  C     | Routine returns total elapsed time for program so far.    
456  C     \==========================================================/  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        Real*8 userTime        Real*8 userTime
466        Real*8 systemTime        Real*8 systemTime
467        Real*8 wallClockTime        Real*8 wallClockTime
468  CEndOfInterface  
469        Real*4 ETIME, ACTUAL, TARRAY(2)  C     !USES:
470    #ifndef TARGET_T3E
471    # ifndef TARGET_CRAY_VECTOR
472    #  ifdef TARGET_PWR3
473          Real*8 system_time, user_time, timenow
474    #  else
475          Real*4 ETIME
476        EXTERNAL ETIME        EXTERNAL ETIME
477    #  endif
478    # endif
479    #endif
480    
481    C     !LOCAL VARIABLES:
482    C     ACTUAL, TARRAY, :: Temps. to hold times
483    C     wTime
484          Real*4 ACTUAL, TARRAY(2)
485        Real*8 wtime        Real*8 wtime
486    CEOP
487    
488  C     Real*8 MPI_Wtime  C     Real*8 MPI_Wtime
489  C     EXTERNAL MPI_Wtime  C     EXTERNAL MPI_Wtime
490    
491    #if (defined (TARGET_PWR3))
492          userTime      = user_time()
493          systemTime    = system_time()
494          wallClockTime = timenow()
495    #elif (defined (TARGET_T3E) || defined (TARGET_CRAY_VECTOR))
496          userTime      = 0.
497          systemTime    = 0.
498          wallClockTime = 0.
499    #else
500        ACTUAL = ETIME(TARRAY)        ACTUAL = ETIME(TARRAY)
       
501        userTime      = TARRAY(1)        userTime      = TARRAY(1)
502        systemTime    = TARRAY(2)        systemTime    = TARRAY(2)
503        CALL CLOC(wTime)        CALL CLOC(wTime)
504        wallClockTime = wtime        wallClockTime = wtime
505    #endif
506    
507  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
508  C     wtime         = MPI_Wtime()  C     wtime         = MPI_Wtime()
# Line 435  C     wallClockTime = 0. Line 515  C     wallClockTime = 0.
515        RETURN        RETURN
516        END        END
517    
518  CStartOfInterface  CBOP
519    
520    C     !ROUTINE: TIMER_PRINTALL
521    
522    C     !INTERFACE:
523        SUBROUTINE TIMER_PRINTALL( myThreadId )        SUBROUTINE TIMER_PRINTALL( myThreadId )
524  C     /==========================================================\        IMPLICIT NONE
525  C     | SUBROUTINE TIMER_PRINTALL                                |  
526  C     | o Print timer information                                |  C     !DESCRIPTION:
527  C     |==========================================================|  C     *==========================================================*
528  C     | Request print out of table of timing from all timers.    |  C     | SUBROUTINE TIMER_PRINTALL                                
529  C     \==========================================================/  C     | o Print timer information                                
530    C     *==========================================================*
531    C     | Request print out of table of timing from all timers.    
532    C     *==========================================================*
533    
534    C     !INPUT PARAMETERS:
535    C     myThreadId :: This threads number
536        INTEGER myThreadId        INTEGER myThreadId
537  CEndOfInterface  CEOP
538  C     Print out value for every timer.  
 C  
539        CALL TIMER_CONTROL( ' ', 'PRINTALL', 'TIMER_PRINTALL' ,        CALL TIMER_CONTROL( ' ', 'PRINTALL', 'TIMER_PRINTALL' ,
540       &                   myThreadId )       &                   myThreadId )
541  C  C
542        RETURN        RETURN
543        END        END
544  C***********************************************************************  
545    CBOP
546    C     !ROUTINE: TIMER_START
547    
548    C     !INTERFACE:
549        SUBROUTINE TIMER_START ( string , myThreadId )        SUBROUTINE TIMER_START ( string , myThreadId )
550  C     Return start timer named "string".        IMPLICIT NONE
551    
552    C     !DESCRIPTION:
553    C     Start timer named "string".
554    
555    C     !INPUT PARAMETERS:
556    C     string     :: Name of timer
557    C     myThreadId :: My thread number
558        CHARACTER*(*) string        CHARACTER*(*) string
559        INTEGER myThreadId        INTEGER myThreadId
560    CEOP
561  C  C
562        CALL TIMER_CONTROL( string, 'START', 'TIMER_START' , myThreadId)        CALL TIMER_CONTROL( string, 'START', 'TIMER_START' , myThreadId)
563  C  C
564        RETURN        RETURN
565        END        END
566  C***********************************************************************  CBOP
567    C     !ROUTINE: TIMER_STOP
568    
569    C     !INTERFACE:
570        SUBROUTINE TIMER_STOP  ( string , myThreadId)        SUBROUTINE TIMER_STOP  ( string , myThreadId)
571  C     Return start timer named "string".        IMPLICIT NONE
572    
573    C     !DESCRIPTION:
574    C     Stop timer named "string".
575    
576    C     !INPUT PARAMETERS:
577    C     string     :: Name of timer
578    C     myThreadId :: My thread number
579        CHARACTER*(*) string        CHARACTER*(*) string
580        INTEGER myThreadId        INTEGER myThreadId
581    CEOP
582  C  C
583        CALL TIMER_CONTROL( string, 'STOP', 'TIMER_STOP' , myThreadId )        CALL TIMER_CONTROL( string, 'STOP', 'TIMER_STOP' , myThreadId )
584  C  C

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.11.4.1

  ViewVC Help
Powered by ViewVC 1.1.22