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
!> 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
subroutine timer_stop(self, name)
class(timer_t), intent(inout), target :: self
character(len=*), intent(in) :: name
character(len=*), intent(in), optional :: name
logical :: error
!$ integer :: omp_get_level, omp_get_ancestor_thread_num
!$ integer :: i
......@@ -235,27 +238,26 @@ module ftimings
error = .false.
if (.not. associated(self%current_node)) then
write(error_unit,'(a)') "Called %stop(""" // trim(name) // """) without first calling %start(""" // trim(name) // &
& """), disabling timings"
write(error_unit,'(a)') "Called timer_stop() without first calling any timer_start(), 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"
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
if (.not. error) then
call self%current_node%stop()
! climb up to parent
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()
self%active = .false.
endif
......
Supports Markdown
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