From 1273c3d0fd75443a5e188a539fd32ec48b058b98 Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Fri, 8 Feb 2019 10:10:01 -0200 Subject: [PATCH] TIMERS: Print error messages to error unit. Signed-off-by: Grzegorz Kowal --- sources/timers.F90 | 80 +++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/sources/timers.F90 b/sources/timers.F90 index 95cbd15..2f6fd87 100644 --- a/sources/timers.F90 +++ b/sources/timers.F90 @@ -153,6 +153,10 @@ module timers ! subroutine set_timer(string, timer) +! include external procedures +! + use iso_fortran_env, only : error_unit + ! local variables are not implicit by default ! implicit none @@ -161,6 +165,10 @@ module timers ! character(len=*), intent(in) :: string integer , intent(out) :: timer + +! local parameters +! + character(len=*), parameter :: loc = 'TIMERS::set_timer()' ! !------------------------------------------------------------------------------- ! @@ -178,12 +186,18 @@ module timers ! set the timer flag ! - tenabled(ntimer) = .true. + tenabled(ntimer) = .true. ! return the timer index ! timer = ntimer + else + + write(error_unit,"('[',a,']: ',a)") trim(loc) & + , "The maximum number of counters exceeded! " // & + "Increase parameter 'ntimers' in this module and recompile." + end if !------------------------------------------------------------------------------- @@ -205,6 +219,10 @@ module timers ! subroutine start_timer(timer) +! include external procedures +! + use iso_fortran_env, only : error_unit + ! local variables are not implicit by default ! implicit none @@ -212,6 +230,10 @@ module timers ! input arguments ! integer, intent(in) :: timer + +! local parameters +! + character(len=*), parameter :: loc = 'TIMERS::start_timer()' ! !------------------------------------------------------------------------------- ! @@ -219,10 +241,8 @@ module timers ! if (tlocked(timer)) then -! the timer is already locked -! - write(*,'("start_timer:: The timer -", a, "- is already locked!")') & - trim(description(timer)) + write(error_unit,"('[',a,']: ',a)") trim(loc) & + , "Timer '" // trim(description(timer)) // "' already locked!" else ! unlocked @@ -255,6 +275,10 @@ module timers ! subroutine stop_timer(timer) +! include external procedures +! + use iso_fortran_env, only : error_unit + ! local variables are not implicit by default ! implicit none @@ -262,6 +286,10 @@ module timers ! input arguments ! integer, intent(in) :: timer + +! local parameters +! + character(len=*), parameter :: loc = 'TIMERS::stop_timer()' ! !------------------------------------------------------------------------------- ! @@ -275,11 +303,11 @@ module timers ! add the time increment ! - times(timer) = times(timer) + (tstop(timer) - tstart(timer)) + times(timer) = times(timer) + (tstop(timer) - tstart(timer)) ! increase the timer count ! - tcount(timer) = tcount(timer) + 1 + tcount(timer) = tcount(timer) + 1 ! unlock the timer ! @@ -287,10 +315,8 @@ module timers else ! unlocked -! the timer is unlocked, nothing to count -! - write(*,'("stop_timer:: The timer -", a, "- is already unlocked!")') & - trim(description(timer)) + write(error_unit,"('[',a,']: ',a)") trim(loc) & + , "Timer '" // trim(description(timer)) // "' already unlocked!" end if ! unlocked @@ -311,7 +337,7 @@ module timers ! !=============================================================================== ! - function get_timer(timer) + real(kind=8) function get_timer(timer) ! local variables are not implicit by default ! @@ -320,10 +346,6 @@ module timers ! input arguments ! integer, intent(in) :: timer - -! return variable -! - real(kind=8) :: get_timer ! !------------------------------------------------------------------------------- ! @@ -352,7 +374,7 @@ module timers ! !=============================================================================== ! - function get_count(timer) + integer(kind=4) function get_count(timer) ! local variables are not implicit by default ! @@ -361,10 +383,6 @@ module timers ! input arguments ! integer, intent(in) :: timer - -! return variable -! - integer(kind=4) :: get_count ! !------------------------------------------------------------------------------- ! @@ -393,7 +411,7 @@ module timers ! !=============================================================================== ! - function timer_enabled(timer) + logical function timer_enabled(timer) ! local variables are not implicit by default ! @@ -402,10 +420,6 @@ module timers ! input arguments ! integer, intent(in) :: timer - -! return variable -! - logical :: timer_enabled ! !------------------------------------------------------------------------------- ! @@ -434,7 +448,7 @@ module timers ! !=============================================================================== ! - function timer_description(timer) + character(len=32) function timer_description(timer) ! local variables are not implicit by default ! @@ -443,10 +457,6 @@ module timers ! input arguments ! integer, intent(in) :: timer - -! return variable -! - character(len=32) :: timer_description ! !------------------------------------------------------------------------------- ! @@ -472,19 +482,15 @@ module timers ! !=============================================================================== ! - function get_timer_total() + real(kind=8) function get_timer_total() ! local variables are not implicit by default ! implicit none -! return value -! - real(kind=8) :: get_timer_total - ! local variables ! - integer(kind=8) :: tend + integer(kind=8) :: tend ! !------------------------------------------------------------------------------- !