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