berry_print_progress Subroutine

private subroutine berry_print_progress(loop_k, start_k, end_k, step_k)

Uses

  • proc~~berry_print_progress~~UsesGraph proc~berry_print_progress berry_print_progress module~w90_comms w90_comms proc~berry_print_progress->module~w90_comms module~w90_io w90_io proc~berry_print_progress->module~w90_io module~w90_comms->module~w90_io module~w90_constants w90_constants module~w90_comms->module~w90_constants module~w90_io->module~w90_constants

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: loop_k
integer, intent(in) :: start_k
integer, intent(in) :: end_k
integer, intent(in) :: step_k

Calls

proc~~berry_print_progress~~CallsGraph proc~berry_print_progress berry_print_progress proc~io_wallclocktime io_wallclocktime proc~berry_print_progress->proc~io_wallclocktime

Contents

Source Code


Source Code

  subroutine berry_print_progress(loop_k, start_k, end_k, step_k)
    !============================================================!
    ! print k-points calculation progress, seperated into 11 points,
    ! from 0%, 10%, ... to 100%
    ! start_k, end_k are inclusive
    ! loop_k should in the array start_k to end_k with step step_k
    !============================================================!
    use w90_comms, only: on_root
    use w90_io, only: stdout, io_wallclocktime

    integer, intent(in) :: loop_k, start_k, end_k, step_k

    real(kind=dp) :: cur_time, finished
    real(kind=dp), save :: prev_time
    integer :: i, j, n, last_k
    logical, dimension(9) :: kmesh_processed = (/(.false., i=1, 9)/)

    if (on_root) then
      ! The last loop_k in the array start:step:end
      ! e.g. 4 of 0:4:7 = [0, 4], 11 of 3:4:11 = [3, 7, 11]
      last_k = (CEILING((end_k - start_k + 1)/real(step_k)) - 1)*step_k + start_k

      if (loop_k == start_k) then
        write (stdout, '(1x,a)') ''
        write (stdout, '(1x,a)') 'Calculation started'
        write (stdout, '(1x,a)') '-------------------------------'
        write (stdout, '(1x,a)') '  k-points       wall      diff'
        write (stdout, '(1x,a)') ' calculated      time      time'
        write (stdout, '(1x,a)') ' ----------      ----      ----'
        cur_time = io_wallclocktime()
        prev_time = cur_time
        write (stdout, '(5x,a,3x,f10.1,f10.1)') '  0%', cur_time, cur_time - prev_time
      else if (loop_k == last_k) then
        cur_time = io_wallclocktime()
        write (stdout, '(5x,a,3x,f10.1,f10.1)') '100%', cur_time, cur_time - prev_time
        write (stdout, '(1x,a)') ''
      else
        finished = 10.0_dp*real(loop_k - start_k + 1)/real(end_k - start_k + 1)
        do n = 1, size(kmesh_processed)
          if ((.not. kmesh_processed(n)) .and. (finished >= n)) then
            do i = n, size(kmesh_processed)
              if (i <= finished) then
                j = i
                kmesh_processed(i) = .true.
              end if
            end do
            cur_time = io_wallclocktime()
            write (stdout, '(5x,i2,a,3x,f10.1,f10.1)') j, '0%', cur_time, cur_time - prev_time
            prev_time = cur_time
            exit
          end if
        end do
      end if
    end if ! on_root

  end subroutine berry_print_progress