overlap_allocate Subroutine

public subroutine overlap_allocate()

Uses

  • proc~~overlap_allocate~~UsesGraph proc~overlap_allocate overlap_allocate module~w90_comms w90_comms proc~overlap_allocate->module~w90_comms module~w90_parameters w90_parameters proc~overlap_allocate->module~w90_parameters module~w90_io w90_io proc~overlap_allocate->module~w90_io module~w90_comms->module~w90_io module~w90_constants w90_constants module~w90_comms->module~w90_constants module~w90_parameters->module~w90_io module~w90_parameters->module~w90_constants module~w90_io->module~w90_constants

Allocate memory to read Mmn and Amn from files This must be called before calling overlap_read

Arguments

None

Calls

proc~~overlap_allocate~~CallsGraph proc~overlap_allocate overlap_allocate proc~comms_array_split comms_array_split proc~overlap_allocate->proc~comms_array_split

Called by

proc~~overlap_allocate~~CalledByGraph proc~overlap_allocate overlap_allocate program~wannier wannier program~wannier->proc~overlap_allocate proc~wannier_run wannier_run proc~wannier_run->proc~overlap_allocate

Contents

Source Code


Source Code

  subroutine overlap_allocate()
    !%%%%%%%%%%%%%%%%%%%%%
    !! Allocate memory to read Mmn and Amn from files
    !! This must be called before calling overlap_read

    use w90_parameters, only: num_bands, num_wann, num_kpts, nntot, timing_level, &
      u_matrix, m_matrix_orig, m_matrix_orig_local, a_matrix, &
      u_matrix_opt, m_matrix, m_matrix_local
    use w90_io, only: io_error, io_stopwatch
    use w90_comms, only: my_node_id, num_nodes, comms_array_split

    integer :: ierr
    ! Needed to split an array on different nodes
    integer, dimension(0:num_nodes - 1) :: counts
    integer, dimension(0:num_nodes - 1) :: displs

    if (timing_level > 0) call io_stopwatch('overlap: allocate', 1)

    call comms_array_split(num_kpts, counts, displs)

    allocate (u_matrix(num_wann, num_wann, num_kpts), stat=ierr)
    if (ierr /= 0) call io_error('Error in allocating u_matrix in overlap_read')
    u_matrix = cmplx_0

    if (disentanglement) then
      if (on_root) then
        allocate (m_matrix_orig(num_bands, num_bands, nntot, num_kpts), stat=ierr)
        if (ierr /= 0) call io_error('Error in allocating m_matrix_orig in overlap_read')
      endif
      allocate (m_matrix_orig_local(num_bands, num_bands, nntot, counts(my_node_id)), stat=ierr)
      if (ierr /= 0) call io_error('Error in allocating m_matrix_orig_local in overlap_read')
      allocate (a_matrix(num_bands, num_wann, num_kpts), stat=ierr)
      if (ierr /= 0) call io_error('Error in allocating a_matrix in overlap_read')
      allocate (u_matrix_opt(num_bands, num_wann, num_kpts), stat=ierr)
      if (ierr /= 0) call io_error('Error in allocating u_matrix_opt in overlap_read')
    else
      if (on_root) then
        allocate (m_matrix(num_wann, num_wann, nntot, num_kpts), stat=ierr)
        if (ierr /= 0) call io_error('Error in allocating m_matrix in overlap_read')
        m_matrix = cmplx_0
      endif
      allocate (m_matrix_local(num_wann, num_wann, nntot, counts(my_node_id)), stat=ierr)
      if (ierr /= 0) call io_error('Error in allocating m_matrix_local in overlap_read')
      m_matrix_local = cmplx_0
    endif

    if (timing_level > 0) call io_stopwatch('overlap: allocate', 2)

  end subroutine overlap_allocate