Commit 9d9387fc authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Allow to omit name in timer_stop

If the argument 'name' is not given to timer_stop, close the currently
active region without further sanity checking.
parent c40d388d
...@@ -210,12 +210,15 @@ module ftimings ...@@ -210,12 +210,15 @@ module ftimings
!> End a timing segment, \sa timer_start !> End a timing segment, \sa timer_start
!> !>
!> \param name The exact same name as was used for %start() !> \param name The exact same name as was used for %start().
!> If not provided, close the currently active region.
!> If given, warns if it does not match the last %start()
!> call on stderr and disables the current timer instance.
!> !>
!> \implements timer_t::stop !> \implements timer_t::stop
subroutine timer_stop(self, name) subroutine timer_stop(self, name)
class(timer_t), intent(inout), target :: self class(timer_t), intent(inout), target :: self
character(len=*), intent(in) :: name character(len=*), intent(in), optional :: name
logical :: error logical :: error
!$ integer :: omp_get_level, omp_get_ancestor_thread_num !$ integer :: omp_get_level, omp_get_ancestor_thread_num
!$ integer :: i !$ integer :: i
...@@ -235,19 +238,18 @@ module ftimings ...@@ -235,19 +238,18 @@ module ftimings
error = .false. error = .false.
if (.not. associated(self%current_node)) then if (.not. associated(self%current_node)) then
write(error_unit,'(a)') "Called %stop(""" // trim(name) // """) without first calling %start(""" // trim(name) // & write(error_unit,'(a)') "Called timer_stop() without first calling any timer_start(), disabling timings"
& """), disabling timings"
call self%free()
self%active = .false.
error = .true.
else if (len(trim(name)) == 0) then
write(error_unit,'(a)') "Warning: Expected %stop(""" // trim(self%current_node%name) // """), but got %stop("""")"
else if (.not. string_eq(self%current_node%name, name)) then
write(error_unit,'(a)') "Expected %stop(""" // trim(self%current_node%name) // """), but got %stop(""" // trim(name) // &
& """), disabling timings"
call self%free() call self%free()
self%active = .false. self%active = .false.
error = .true. error = .true.
else if (present(name)) then
if (.not. string_eq(self%current_node%name, name)) then
write(error_unit,'(a)') "Expected %stop(""" // trim(self%current_node%name) // """),&
& but got %stop(""" // trim(name) // """), disabling timings"
call self%free()
self%active = .false.
error = .true.
endif
endif endif
if (.not. error) then if (.not. error) then
...@@ -255,7 +257,7 @@ module ftimings ...@@ -255,7 +257,7 @@ module ftimings
! climb up to parent ! climb up to parent
if (.not. associated(self%current_node%parent)) then if (.not. associated(self%current_node%parent)) then
write(error_unit,'(a)') "Error: No valid parent node found for node '" // trim(name) // "'" write(error_unit,'(a)') "Error: No valid parent node found for node '" // trim(self%current_node%name) // "'"
call self%free() call self%free()
self%active = .false. self%active = .false.
endif endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment