berry_print_progress Subroutine

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

Uses

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

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: end_k
integer, intent(in) :: loop_k
integer, intent(in) :: start_k
integer, intent(in) :: step_k
integer, intent(in) :: stdout

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

Called by

proc~~berry_print_progress~~CalledByGraph proc~berry_print_progress berry_print_progress proc~berry_main berry_main proc~berry_main->proc~berry_print_progress program~postw90 postw90 program~postw90->proc~berry_main

Source Code

  subroutine berry_print_progress(end_k, loop_k, start_k, step_k, stdout)
    !================================================!
    ! 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
    !
    ! only call from root MPI process!
    !================================================!

    use w90_io, only: io_wallclocktime

    implicit none

    ! arguments
    integer, intent(in) :: loop_k, start_k, end_k, step_k, stdout

    ! local variables
    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)/)

    ! 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 subroutine berry_print_progress