Stops a timer and accumulates the elapsed time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
subroutine profiler_stop(name) character(len=*), intent(in) :: name integer :: idx, parent real(rk) :: elapsed if (.not. profiling_enabled) return if (stack_depth <= 0) then write(error_unit,'(a,a)') 'profiler: stop with empty stack: ', trim(name) error stop 1 end if idx = find_or_create_timer(name) if (stack_ids(stack_depth) /= idx) then write(error_unit,'(a)') 'profiler: mismatched profiler_stop' write(error_unit,'(a,a)') ' expected: ', trim(timers(stack_ids(stack_depth))%name) write(error_unit,'(a,a)') ' got: ', trim(name) error stop 1 end if elapsed = real(MPI_Wtime(), rk) - stack_start(stack_depth) timers(idx)%total_time = timers(idx)%total_time + elapsed timers(idx)%calls = timers(idx)%calls + 1 if (nested_enabled) then if (stack_depth > 1) then parent = stack_ids(stack_depth - 1) else parent = 0 end if call record_edge(parent, idx, elapsed) end if stack_ids(stack_depth) = 0 stack_start(stack_depth) = 0.0_rk stack_depth = stack_depth - 1 end subroutine profiler_stop