w90_readwrite_chkpt_dist Subroutine

public subroutine w90_readwrite_chkpt_dist(dis_manifold, wannier_data, u_matrix, u_matrix_opt, m_matrix, m_matrix_local, omega_invariant, num_bands, num_kpts, num_wann, nntot, checkpoint, have_disentangled, distk, error, comm)

Uses

  • proc~~w90_readwrite_chkpt_dist~~UsesGraph proc~w90_readwrite_chkpt_dist w90_readwrite_chkpt_dist module~w90_comms w90_comms proc~w90_readwrite_chkpt_dist->module~w90_comms module~w90_constants w90_constants proc~w90_readwrite_chkpt_dist->module~w90_constants module~w90_error w90_error proc~w90_readwrite_chkpt_dist->module~w90_error module~w90_io w90_io proc~w90_readwrite_chkpt_dist->module~w90_io module~w90_comms->module~w90_constants module~w90_error_base w90_error_base module~w90_comms->module~w90_error_base module~w90_error->module~w90_comms module~w90_error->module~w90_error_base module~w90_io->module~w90_constants

Distribute the chk files

Arguments

Type IntentOptional Attributes Name
type(dis_manifold_type), intent(inout) :: dis_manifold
type(wannier_data_type), intent(inout) :: wannier_data
complex(kind=dp), intent(inout) :: u_matrix(:,:,:)
complex(kind=dp), intent(inout) :: u_matrix_opt(:,:,:)
complex(kind=dp), intent(inout) :: m_matrix(:,:,:,:)
complex(kind=dp), intent(inout) :: m_matrix_local(:,:,:,:)
real(kind=dp), intent(inout) :: omega_invariant
integer, intent(in) :: num_bands
integer, intent(in) :: num_kpts
integer, intent(in) :: num_wann
integer, intent(in) :: nntot
character(len=20), intent(inout) :: checkpoint
logical, intent(inout) :: have_disentangled
integer, intent(in) :: distk(:)
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_chkpt_dist~~CallsGraph proc~w90_readwrite_chkpt_dist w90_readwrite_chkpt_dist interface~comms_bcast comms_bcast proc~w90_readwrite_chkpt_dist->interface~comms_bcast proc~mpirank mpirank proc~w90_readwrite_chkpt_dist->proc~mpirank proc~set_error_alloc set_error_alloc proc~w90_readwrite_chkpt_dist->proc~set_error_alloc 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_logical comms_bcast_logical interface~comms_bcast->proc~comms_bcast_logical proc~comms_bcast_real comms_bcast_real interface~comms_bcast->proc~comms_bcast_real proc~comms_sync_error comms_sync_error proc~set_error_alloc->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_alloc->proc~set_base_error proc~comms_bcast_char->proc~comms_sync_error proc~comms_no_sync_bcast_char comms_no_sync_bcast_char proc~comms_bcast_char->proc~comms_no_sync_bcast_char proc~comms_bcast_cmplx->proc~comms_sync_error proc~comms_no_sync_bcast_cmplx comms_no_sync_bcast_cmplx proc~comms_bcast_cmplx->proc~comms_no_sync_bcast_cmplx proc~comms_bcast_int->proc~comms_sync_error proc~comms_no_sync_bcast_int comms_no_sync_bcast_int proc~comms_bcast_int->proc~comms_no_sync_bcast_int proc~comms_bcast_logical->proc~comms_sync_error proc~comms_no_sync_bcast_logical comms_no_sync_bcast_logical proc~comms_bcast_logical->proc~comms_no_sync_bcast_logical proc~comms_bcast_real->proc~comms_sync_error proc~comms_no_sync_bcast_real comms_no_sync_bcast_real proc~comms_bcast_real->proc~comms_no_sync_bcast_real

Called by

proc~~w90_readwrite_chkpt_dist~~CalledByGraph proc~w90_readwrite_chkpt_dist w90_readwrite_chkpt_dist proc~read_chkpt read_chkpt proc~read_chkpt->proc~w90_readwrite_chkpt_dist program~wannier wannier program~wannier->proc~read_chkpt

Source Code

  subroutine w90_readwrite_chkpt_dist(dis_manifold, wannier_data, u_matrix, u_matrix_opt, &
                                      m_matrix, m_matrix_local, omega_invariant, num_bands, &
                                      num_kpts, num_wann, nntot, checkpoint, have_disentangled, &
                                      distk, error, comm)
    !================================================!
    !
    !! Distribute the chk files
    !
    !================================================!

    use w90_constants, only: dp
    use w90_io, only: io_date, io_time
    use w90_comms, only: comms_bcast, w90_comm_type, mpirank
    use w90_error, only: w90_error_type, set_error_alloc

    implicit none

    ! arguments
    type(wannier_data_type), intent(inout) :: wannier_data
    type(dis_manifold_type), intent(inout) :: dis_manifold
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    integer, intent(in) :: num_bands
    integer, intent(in) :: num_wann
    integer, intent(in) :: num_kpts
    integer, intent(in) :: nntot
    integer, intent(in) :: distk(:)

    complex(kind=dp), intent(inout) :: u_matrix(:, :, :)
    complex(kind=dp), intent(inout) :: u_matrix_opt(:, :, :)
    complex(kind=dp), intent(inout) :: m_matrix_local(:, :, :, :)
    complex(kind=dp), intent(inout) :: m_matrix(:, :, :, :) !only alloc/assigned on root
    real(kind=dp), intent(inout) :: omega_invariant

    character(len=20), intent(inout) :: checkpoint
    logical, intent(inout) :: have_disentangled

    ! local variables
    integer :: ierr, ikl, nkl, ikg, rank
    logical :: on_root = .false.

    rank = mpirank(comm)
    if (rank == 0) on_root = .true.

    call comms_bcast(checkpoint, len(checkpoint), error, comm)
    if (allocated(error)) return

    ! assumes u is alloc'd on all nodes
    call comms_bcast(u_matrix(1, 1, 1), num_wann*num_wann*num_kpts, error, comm)
    if (allocated(error)) return

    ! assumes m is alloc'd on all nodes
    call comms_bcast(m_matrix(1, 1, 1, 1), num_wann*num_wann*nntot*num_kpts, error, comm)
    if (allocated(error)) return

    ! copy global m into local m
    nkl = count(distk(:) == rank)
    ikl = 1
    do ikg = 1, num_kpts
      if (distk(ikg) == rank) then
        m_matrix_local(:num_wann, :num_wann, :, ikl) = m_matrix(:, :, :, ikg)
        ikl = ikl + 1
      end if
    end do

    call comms_bcast(have_disentangled, 1, error, comm)
    if (allocated(error)) return

    if (have_disentangled) then
      if (.not. on_root) then

        if (.not. allocated(dis_manifold%lwindow)) then
          allocate (dis_manifold%lwindow(num_bands, num_kpts), stat=ierr)
          if (ierr /= 0) then
            call set_error_alloc(error, 'Error allocating lwindow in w90_readwrite_chkpt_dist', comm)
            return
          end if
        end if

        if (.not. allocated(dis_manifold%ndimwin)) then
          allocate (dis_manifold%ndimwin(num_kpts), stat=ierr)
          if (ierr /= 0) then
            call set_error_alloc(error, 'Error allocating ndimwin in w90_readwrite_chkpt_dist', comm)
            return
          end if
        end if
      end if

      call comms_bcast(dis_manifold%lwindow(1, 1), num_bands*num_kpts, error, comm)
      if (allocated(error)) return
      call comms_bcast(dis_manifold%ndimwin(1), num_kpts, error, comm)
      if (allocated(error)) return
      call comms_bcast(omega_invariant, 1, error, comm)
      if (allocated(error)) return
    end if

    call comms_bcast(u_matrix_opt(1, 1, 1), num_bands*num_wann*num_kpts, error, comm)
    if (allocated(error)) return
    call comms_bcast(wannier_data%centres(1, 1), 3*num_wann, error, comm)
    if (allocated(error)) return
    call comms_bcast(wannier_data%spreads(1), num_wann, error, comm)
    if (allocated(error)) return
  end subroutine w90_readwrite_chkpt_dist