pw90common_wanint_get_kpoint_file Subroutine

public subroutine pw90common_wanint_get_kpoint_file()

Uses

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

read kpoints from kpoint.dat and distribute

Arguments

None

Calls

proc~~pw90common_wanint_get_kpoint_file~~CallsGraph proc~pw90common_wanint_get_kpoint_file pw90common_wanint_get_kpoint_file interface~comms_bcast comms_bcast proc~pw90common_wanint_get_kpoint_file->interface~comms_bcast proc~io_file_unit io_file_unit proc~pw90common_wanint_get_kpoint_file->proc~io_file_unit proc~comms_bcast_char comms_bcast_char interface~comms_bcast->proc~comms_bcast_char proc~comms_bcast_cmplx comms_bcast_cmplx interface~comms_bcast->proc~comms_bcast_cmplx proc~comms_bcast_int comms_bcast_int interface~comms_bcast->proc~comms_bcast_int proc~comms_bcast_real comms_bcast_real interface~comms_bcast->proc~comms_bcast_real proc~comms_bcast_logical comms_bcast_logical interface~comms_bcast->proc~comms_bcast_logical

Contents


Source Code

  subroutine pw90common_wanint_get_kpoint_file
    !===========================================================!
    !                                                           !
    !! read kpoints from kpoint.dat and distribute
    !                                                           !
    !===========================================================!

    use w90_constants, only: dp
    use w90_io, only: io_error, io_file_unit, &
      io_date, io_time, io_stopwatch

    integer       :: k_unit
    integer       :: loop_nodes, loop_kpt, i, ierr
    real(kind=dp) :: sum

    k_unit = io_file_unit()
    if (on_root) then
      open (unit=k_unit, file='kpoint.dat', status='old', form='formatted', err=106)
      read (k_unit, *) num_int_kpts
    end if
    call comms_bcast(num_int_kpts, 1)

    allocate (num_int_kpts_on_node(0:num_nodes - 1))
    num_int_kpts_on_node(:) = num_int_kpts/num_nodes
    max_int_kpts_on_node = num_int_kpts - (num_nodes - 1)*(num_int_kpts/num_nodes)
    num_int_kpts_on_node(0) = max_int_kpts_on_node
!    if(my_node_id < num_int_kpts- num_int_kpts_on_node*num_nodes)  num_int_kpts_on_node= num_int_kpts_on_node+1

    allocate (int_kpts(3, max_int_kpts_on_node), stat=ierr)
    if (ierr /= 0) call io_error('Error allocating max_int_kpts_on_node in param_read_um')
    int_kpts = 0.0_dp
    allocate (weight(max_int_kpts_on_node), stat=ierr)
    if (ierr /= 0) call io_error('Error allocating weight in param_read_um')
    weight = 0.0_dp

    sum = 0.0_dp
    if (on_root) then
      do loop_nodes = 1, num_nodes - 1
        do loop_kpt = 1, num_int_kpts_on_node(loop_nodes)
          read (k_unit, *) (int_kpts(i, loop_kpt), i=1, 3), weight(loop_kpt)
          sum = sum + weight(loop_kpt)
        end do

        call comms_send(int_kpts(1, 1), 3*num_int_kpts_on_node(loop_nodes), loop_nodes)
        call comms_send(weight(1), num_int_kpts_on_node(loop_nodes), loop_nodes)

      end do
      do loop_kpt = 1, num_int_kpts_on_node(0)
        read (k_unit, *) (int_kpts(i, loop_kpt), i=1, 3), weight(loop_kpt)
        sum = sum + weight(loop_kpt)
      end do
!       print*,'rsum',sum
    end if

    if (.not. on_root) then
      call comms_recv(int_kpts(1, 1), 3*num_int_kpts_on_node(my_node_id), root_id)
      call comms_recv(weight(1), num_int_kpts_on_node(my_node_id), root_id)

    end if

    return

106 call io_error('Error: Problem opening file kpoint.dat in pw90common_wanint_get_kpoint_file')

  end subroutine pw90common_wanint_get_kpoint_file