SUBROUTINE cpu_log( log_event, place, modus, barrierwait ) !------------------------------------------------------------------------------! ! Actual revisions: ! ----------------- ! Type of count and count_rate changed to default INTEGER on NEC machines ! ! Former revisions: ! ----------------- ! $Id: cpu_log.f90 239 2009-02-17 13:27:28Z raasch $ ! ! 225 2009-01-26 14:44:20Z raasch ! Type of count and count_rate changed to INTEGER(8) ! ! 82 2007-04-16 15:40:52Z raasch ! Preprocessor strings for different linux clusters changed to "lc", ! preprocessor directives for old systems removed ! ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.24 2006/06/02 15:12:17 raasch ! cpp-directives extended for lctit ! ! Revision 1.1 1997/07/24 11:12:29 raasch ! Initial revision ! ! ! Description: ! ------------ ! Cpu-time measurements for any program part whatever. !------------------------------------------------------------------------------! USE cpulog USE pegrid IMPLICIT NONE CHARACTER (LEN=*) :: modus, place CHARACTER (LEN=*), OPTIONAL :: barrierwait LOGICAL, SAVE :: first = .TRUE. REAL :: mtime = 0.0, mtimevec = 0.0 TYPE(logpoint) :: log_event #if defined( __lc ) || defined( __decalpha ) INTEGER(8) :: count, count_rate #elif defined( __nec ) INTEGER :: count, count_rate #elif defined( __ibm ) INTEGER(8) :: IRTC #endif ! !-- Initialize and check, respectively, point of measurement IF ( log_event%place == ' ' ) THEN log_event%place = place ELSEIF ( log_event%place /= place ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ cpu_log: wrong argument' PRINT*,' expected: ',log_event%place,' given: ', place ENDIF CALL local_stop ENDIF ! !-- Take current time #if defined( __lc ) || defined( __decalpha ) || defined( __nec ) CALL SYSTEM_CLOCK( count, count_rate ) mtime = REAL( count ) / REAL( count_rate ) #elif defined( __ibm ) mtime = IRTC( ) * 1E-9 #else IF ( myid == 0 ) THEN PRINT*, '+++ cpu_log: no time measurement defined on this host' ENDIF CALL local_stop #endif ! !-- Start, stop or pause measurement IF ( modus == 'start' .OR. modus == 'continue' ) THEN log_event%mtime = mtime log_event%mtimevec = mtimevec ELSEIF ( modus == 'pause' ) THEN IF ( ( mtime - log_event%mtime ) < 0.0 .AND. first ) THEN PRINT*,'+++ WARNING: cpu_log: negative time interval occured' PRINT*,'+++ PE',myid,' L=PAUSE "',TRIM(log_event%place),'" new=', & mtime,' last=',log_event%mtime first = .FALSE. ENDIF log_event%isum = log_event%isum + mtime - log_event%mtime log_event%ivect = log_event%ivect + mtimevec - log_event%mtimevec ELSEIF ( modus == 'stop' ) THEN IF ( ( mtime - log_event%mtime + log_event%isum ) < 0.0 .AND. & first ) THEN PRINT*,'+++ WARNING: cpu_log: negative time interval occured' PRINT*,'+++ PE',myid,' L=STOP "',TRIM(log_event%place),'" new=', & mtime,' last=',log_event%mtime,' isum=',log_event%isum first = .FALSE. ENDIF log_event%mtime = mtime - log_event%mtime + log_event%isum log_event%mtimevec = mtimevec - log_event%mtimevec + log_event%ivect log_event%sum = log_event%sum + log_event%mtime IF ( log_event%sum < 0.0 .AND. first ) THEN PRINT*,'+++ WARNING: cpu_log: negative time interval occured' PRINT*,'+++ PE',myid,' L=STOP "',TRIM(log_event%place),'" sum=', & log_event%sum,' mtime=',log_event%mtime first = .FALSE. ENDIF log_event%vector = log_event%vector + log_event%mtimevec log_event%counts = log_event%counts + 1 log_event%isum = 0.0 log_event%ivect = 0.0 ELSE PRINT*, '+++ unknown modus of time measurement: ', modus ENDIF END SUBROUTINE cpu_log