1 | SUBROUTINE cpu_log( log_event, place, modus, barrierwait ) |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! Preprocessor strings for different linux clusters changed to "lc", |
---|
7 | ! preprocessor directives for old systems removed |
---|
8 | ! |
---|
9 | ! Former revisions: |
---|
10 | ! ----------------- |
---|
11 | ! $Id: cpu_log.f90 82 2007-04-16 15:40:52Z raasch $ |
---|
12 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
13 | ! |
---|
14 | ! Revision 1.24 2006/06/02 15:12:17 raasch |
---|
15 | ! cpp-directives extended for lctit |
---|
16 | ! |
---|
17 | ! Revision 1.1 1997/07/24 11:12:29 raasch |
---|
18 | ! Initial revision |
---|
19 | ! |
---|
20 | ! |
---|
21 | ! Description: |
---|
22 | ! ------------ |
---|
23 | ! Cpu-time measurements for any program part whatever. |
---|
24 | !------------------------------------------------------------------------------! |
---|
25 | |
---|
26 | USE cpulog |
---|
27 | USE pegrid |
---|
28 | |
---|
29 | IMPLICIT NONE |
---|
30 | |
---|
31 | CHARACTER (LEN=*) :: modus, place |
---|
32 | CHARACTER (LEN=*), OPTIONAL :: barrierwait |
---|
33 | LOGICAL, SAVE :: first = .TRUE. |
---|
34 | REAL :: mtime = 0.0, mtimevec = 0.0 |
---|
35 | TYPE(logpoint) :: log_event |
---|
36 | |
---|
37 | #if defined( __lc ) || defined( __decalpha ) || defined( __nec ) |
---|
38 | INTEGER :: count, count_rate |
---|
39 | #elif defined( __ibm ) |
---|
40 | INTEGER(8) :: IRTC |
---|
41 | #endif |
---|
42 | |
---|
43 | |
---|
44 | ! |
---|
45 | !-- Initialize and check, respectively, point of measurement |
---|
46 | IF ( log_event%place == ' ' ) THEN |
---|
47 | log_event%place = place |
---|
48 | ELSEIF ( log_event%place /= place ) THEN |
---|
49 | IF ( myid == 0 ) THEN |
---|
50 | PRINT*,'+++ cpu_log: wrong argument' |
---|
51 | PRINT*,' expected: ',log_event%place,' given: ', place |
---|
52 | ENDIF |
---|
53 | CALL local_stop |
---|
54 | ENDIF |
---|
55 | |
---|
56 | ! |
---|
57 | !-- Take current time |
---|
58 | #if defined( __lc ) || defined( __decalpha ) || defined( __nec ) |
---|
59 | CALL SYSTEM_CLOCK( count, count_rate ) |
---|
60 | mtime = REAL( count ) / REAL( count_rate ) |
---|
61 | #elif defined( __ibm ) |
---|
62 | mtime = IRTC( ) * 1E-9 |
---|
63 | #else |
---|
64 | IF ( myid == 0 ) THEN |
---|
65 | PRINT*, '+++ cpu_log: no time measurement defined on this host' |
---|
66 | ENDIF |
---|
67 | CALL local_stop |
---|
68 | #endif |
---|
69 | |
---|
70 | ! |
---|
71 | !-- Start, stop or pause measurement |
---|
72 | IF ( modus == 'start' .OR. modus == 'continue' ) THEN |
---|
73 | log_event%mtime = mtime |
---|
74 | log_event%mtimevec = mtimevec |
---|
75 | ELSEIF ( modus == 'pause' ) THEN |
---|
76 | IF ( ( mtime - log_event%mtime ) < 0.0 .AND. first ) THEN |
---|
77 | PRINT*,'+++ WARNING: cpu_log: negative time interval occured' |
---|
78 | PRINT*,'+++ PE',myid,' L=PAUSE "',TRIM(log_event%place),'" new=', & |
---|
79 | mtime,' last=',log_event%mtime |
---|
80 | first = .FALSE. |
---|
81 | ENDIF |
---|
82 | log_event%isum = log_event%isum + mtime - log_event%mtime |
---|
83 | log_event%ivect = log_event%ivect + mtimevec - log_event%mtimevec |
---|
84 | ELSEIF ( modus == 'stop' ) THEN |
---|
85 | IF ( ( mtime - log_event%mtime + log_event%isum ) < 0.0 .AND. & |
---|
86 | first ) THEN |
---|
87 | PRINT*,'+++ WARNING: cpu_log: negative time interval occured' |
---|
88 | PRINT*,'+++ PE',myid,' L=STOP "',TRIM(log_event%place),'" new=', & |
---|
89 | mtime,' last=',log_event%mtime,' isum=',log_event%isum |
---|
90 | first = .FALSE. |
---|
91 | ENDIF |
---|
92 | log_event%mtime = mtime - log_event%mtime + log_event%isum |
---|
93 | log_event%mtimevec = mtimevec - log_event%mtimevec + log_event%ivect |
---|
94 | log_event%sum = log_event%sum + log_event%mtime |
---|
95 | IF ( log_event%sum < 0.0 .AND. first ) THEN |
---|
96 | PRINT*,'+++ WARNING: cpu_log: negative time interval occured' |
---|
97 | PRINT*,'+++ PE',myid,' L=STOP "',TRIM(log_event%place),'" sum=', & |
---|
98 | log_event%sum,' mtime=',log_event%mtime |
---|
99 | first = .FALSE. |
---|
100 | ENDIF |
---|
101 | log_event%vector = log_event%vector + log_event%mtimevec |
---|
102 | log_event%counts = log_event%counts + 1 |
---|
103 | log_event%isum = 0.0 |
---|
104 | log_event%ivect = 0.0 |
---|
105 | ELSE |
---|
106 | PRINT*, '+++ unknown modus of time measurement: ', modus |
---|
107 | ENDIF |
---|
108 | |
---|
109 | |
---|
110 | END SUBROUTINE cpu_log |
---|