SUBROUTINE cpu_log( log_event, place, modus, barrierwait ) !------------------------------------------------------------------------------! ! Actual revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Log: cpu_log.f90,v $ ! Revision 1.24 2006/06/02 15:12:17 raasch ! cpp-directives extended for lctit ! ! Revision 1.23 2004/01/28 15:08:52 raasch ! Type log changed to logpoint due to name conflict with intrinsic log ! ! Revision 1.22 2003/05/09 14:15:18 raasch ! Time measurement on linux machines included, measurements on IBM are now using ! function irtc, which allows correct measurements for jobs running over ! the 24:00 timeline ! ! Revision 1.21 2003/03/16 09:30:04 raasch ! Two underscores (_) are placed in front of all define-strings ! ! Revision 1.20 2003/03/12 16:24:18 raasch ! Time measurement on NEC implemented ! ! Revision 1.19 2002/12/20 09:38:43 raasch ! variable first is defined for all hosts ! ! Revision 1.18 2002/12/19 14:09:36 raasch ! Output of warnings in case of negative cpu-times, STOP statement replaced by ! call of subroutine local_stop ! ! Revision 1.17 2002/05/02 18:49:37 raasch ! Time measurement on IBM implemented ! ! Revision 1.16 2001/03/30 07:00:43 raasch ! Translation of remaining German identifiers (variables, subroutines, etc.) ! ! Revision 1.14 2001/01/25 06:56:49 raasch ! +cpp-directives for dec-alpha-workstations ! ! Revision 1.13 2001/01/22 08:32:46 raasch ! Module test_variables removed ! ! Revision 1.11 2000/12/20 10:18:58 letzel ! All comments translated into English. ! ! Revision 1.9 1999/11/25 16:19:07 raasch ! TIMEF jetzt als Function-Aufruf ! ! Revision 1.8 1999/03/03 09:26:14 raasch ! Zeitmessung auf T3E grundsaetzlich auf TIMEF umgestellt ! ! Revision 1.7 1998/12/15 07:32:39 raasch ! Messung der wahren I/O-Zeiten auf T3E mit TIMEF moeglich ! ! Revision 1.4 1997/09/16 06:37:24 raasch ! Zeitmessungen auf t3e umgestellt auf tsecnd (schneller als mpi_wtime) ! ! 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( __lcmuk ) || defined( __lctit ) || defined( __hpmuk ) || defined( __decalpha ) || defined( __nec ) INTEGER :: count, count_rate #elif defined( __ibm ) INTEGER(8) :: IRTC #elif defined( __t3eb ) REAL :: TIMEF #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( __lcmuk ) || defined( __lctit ) || defined( __hpmuk ) || defined( __decalpha ) || defined( __nec ) CALL SYSTEM_CLOCK( count, count_rate ) mtime = REAL( count ) / REAL( count_rate ) #elif defined( __ibm ) mtime = IRTC( ) * 1E-9 !#elif defined( __vpp ) ! CALL CLOCKV ( mtimevec, mtime, 0, 2 ) #elif defined( __t3eb ) || defined( __t3eh ) || defined( __t3ej2 ) || defined( __t3ej5 ) #if defined( __parallel ) IF ( .NOT. PRESENT( barrierwait ) ) THEN CALL MPI_BARRIER( comm2d, ierr ) CONTINUE ENDIF #endif mtime = TIMEF( ) mtime = mtime * 0.001 #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