TIMERS: Print error messages to error unit.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2019-02-08 10:10:01 -02:00
parent dc8c1aaaa7
commit 1273c3d0fd

View File

@ -153,6 +153,10 @@ module timers
! !
subroutine set_timer(string, timer) subroutine set_timer(string, timer)
! include external procedures
!
use iso_fortran_env, only : error_unit
! local variables are not implicit by default ! local variables are not implicit by default
! !
implicit none implicit none
@ -161,6 +165,10 @@ module timers
! !
character(len=*), intent(in) :: string character(len=*), intent(in) :: string
integer , intent(out) :: timer integer , intent(out) :: timer
! local parameters
!
character(len=*), parameter :: loc = 'TIMERS::set_timer()'
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -178,12 +186,18 @@ module timers
! set the timer flag ! set the timer flag
! !
tenabled(ntimer) = .true. tenabled(ntimer) = .true.
! return the timer index ! return the timer index
! !
timer = ntimer 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 end if
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
@ -205,6 +219,10 @@ module timers
! !
subroutine start_timer(timer) subroutine start_timer(timer)
! include external procedures
!
use iso_fortran_env, only : error_unit
! local variables are not implicit by default ! local variables are not implicit by default
! !
implicit none implicit none
@ -212,6 +230,10 @@ module timers
! input arguments ! input arguments
! !
integer, intent(in) :: timer integer, intent(in) :: timer
! local parameters
!
character(len=*), parameter :: loc = 'TIMERS::start_timer()'
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -219,10 +241,8 @@ module timers
! !
if (tlocked(timer)) then if (tlocked(timer)) then
! the timer is already locked write(error_unit,"('[',a,']: ',a)") trim(loc) &
! , "Timer '" // trim(description(timer)) // "' already locked!"
write(*,'("start_timer:: The timer -", a, "- is already locked!")') &
trim(description(timer))
else ! unlocked else ! unlocked
@ -255,6 +275,10 @@ module timers
! !
subroutine stop_timer(timer) subroutine stop_timer(timer)
! include external procedures
!
use iso_fortran_env, only : error_unit
! local variables are not implicit by default ! local variables are not implicit by default
! !
implicit none implicit none
@ -262,6 +286,10 @@ module timers
! input arguments ! input arguments
! !
integer, intent(in) :: timer integer, intent(in) :: timer
! local parameters
!
character(len=*), parameter :: loc = 'TIMERS::stop_timer()'
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -275,11 +303,11 @@ module timers
! add the time increment ! add the time increment
! !
times(timer) = times(timer) + (tstop(timer) - tstart(timer)) times(timer) = times(timer) + (tstop(timer) - tstart(timer))
! increase the timer count ! increase the timer count
! !
tcount(timer) = tcount(timer) + 1 tcount(timer) = tcount(timer) + 1
! unlock the timer ! unlock the timer
! !
@ -287,10 +315,8 @@ module timers
else ! unlocked else ! unlocked
! the timer is unlocked, nothing to count write(error_unit,"('[',a,']: ',a)") trim(loc) &
! , "Timer '" // trim(description(timer)) // "' already unlocked!"
write(*,'("stop_timer:: The timer -", a, "- is already unlocked!")') &
trim(description(timer))
end if ! 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 ! local variables are not implicit by default
! !
@ -320,10 +346,6 @@ module timers
! input arguments ! input arguments
! !
integer, intent(in) :: timer 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 ! local variables are not implicit by default
! !
@ -361,10 +383,6 @@ module timers
! input arguments ! input arguments
! !
integer, intent(in) :: timer 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 ! local variables are not implicit by default
! !
@ -402,10 +420,6 @@ module timers
! input arguments ! input arguments
! !
integer, intent(in) :: timer 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 ! local variables are not implicit by default
! !
@ -443,10 +457,6 @@ module timers
! input arguments ! input arguments
! !
integer, intent(in) :: timer 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 ! local variables are not implicit by default
! !
implicit none implicit none
! return value
!
real(kind=8) :: get_timer_total
! local variables ! local variables
! !
integer(kind=8) :: tend integer(kind=8) :: tend
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !