overlap_allocate Subroutine

public subroutine overlap_allocate(a_matrix, m_matrix, m_matrix_local, m_matrix_orig, m_matrix_orig_local, u_matrix, u_matrix_opt, nntot, num_bands, num_kpts, num_wann, timing_level, timer, dist_k, error, comm)

Uses

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

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

Arguments

Type IntentOptional Attributes Name
complex(kind=dp), allocatable :: a_matrix(:,:,:)
complex(kind=dp), allocatable :: m_matrix(:,:,:,:)
complex(kind=dp), allocatable :: m_matrix_local(:,:,:,:)
complex(kind=dp), allocatable :: m_matrix_orig(:,:,:,:)
complex(kind=dp), allocatable :: m_matrix_orig_local(:,:,:,:)
complex(kind=dp), allocatable :: u_matrix(:,:,:)
complex(kind=dp), allocatable :: u_matrix_opt(:,:,:)
integer, intent(in) :: nntot
integer, intent(in) :: num_bands
integer, intent(in) :: num_kpts
integer, intent(in) :: num_wann
integer, intent(in) :: timing_level
type(timer_list_type), intent(inout) :: timer
integer, intent(in) :: dist_k(:)
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~overlap_allocate~~CallsGraph proc~overlap_allocate overlap_allocate proc~io_stopwatch_start io_stopwatch_start proc~overlap_allocate->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~overlap_allocate->proc~io_stopwatch_stop proc~mpirank mpirank proc~overlap_allocate->proc~mpirank proc~set_error_alloc set_error_alloc proc~overlap_allocate->proc~set_error_alloc 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

Source Code

  subroutine overlap_allocate(a_matrix, m_matrix, m_matrix_local, m_matrix_orig, &
                              m_matrix_orig_local, u_matrix, u_matrix_opt, nntot, num_bands, &
                              num_kpts, num_wann, timing_level, timer, dist_k, error, comm)
    !================================================!
    !! Allocate memory to read Mmn and Amn from files
    !! This must be called before calling overlap_read
    !
    !================================================!

    use w90_io, only: io_stopwatch_start, io_stopwatch_stop
    use w90_types, only: timer_list_type
    use w90_error

    ! arguments
    integer, intent(in) :: nntot
    integer, intent(in) :: num_bands
    integer, intent(in) :: num_kpts
    integer, intent(in) :: num_wann
    integer, intent(in) :: timing_level
    integer, intent(in) :: dist_k(:)

    complex(kind=dp), allocatable :: a_matrix(:, :, :)
    complex(kind=dp), allocatable :: m_matrix(:, :, :, :)  !root only
    complex(kind=dp), allocatable :: m_matrix_local(:, :, :, :)
    complex(kind=dp), allocatable :: m_matrix_orig(:, :, :, :)  !root only
    complex(kind=dp), allocatable :: m_matrix_orig_local(:, :, :, :)  !root only
    complex(kind=dp), allocatable :: u_matrix(:, :, :)
    complex(kind=dp), allocatable :: u_matrix_opt(:, :, :)

    type(timer_list_type), intent(inout) :: timer
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    ! local variables
    integer :: ierr
    integer :: my_node_id, nkl
    logical :: disentanglement
    logical :: on_root = .false.

    disentanglement = (num_bands > num_wann)

    my_node_id = mpirank(comm)
    nkl = count(dist_k == my_node_id) ! number of k on this rank

    if (my_node_id == 0) on_root = .true.

    if (timing_level > 0) call io_stopwatch_start('overlap: allocate', timer)

    if (disentanglement) then
      if (on_root) then
        allocate (m_matrix_orig(num_bands, num_bands, nntot, num_kpts), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error in allocating m_matrix_orig in overlap_allocate', comm)
          return
        end if
      end if
      allocate (m_matrix_orig_local(num_bands, num_bands, nntot, nkl), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error in allocating m_matrix_orig_local in overlap_allocate', comm)
        return
      end if
      m_matrix_orig = cmplx_0
      m_matrix_orig_local = cmplx_0
    end if

    if (on_root) then
      allocate (m_matrix(num_wann, num_wann, nntot, num_kpts), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error in allocating m_matrix in overlap_allocate', comm)
        return
      end if
      m_matrix = cmplx_0
      !else
      !allocate (m_matrix(0, 0, 0, 0))
    end if
    allocate (m_matrix_local(num_wann, num_wann, nntot, nkl), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating m_matrix_local in overlap_allocate', comm)
      return
    end if
    m_matrix_local = cmplx_0

    allocate (a_matrix(num_bands, num_wann, num_kpts), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating a_matrix in overlap_allocate', comm)
      return
    end if
    allocate (u_matrix(num_wann, num_wann, num_kpts), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating u_matrix in overlap_allocate', comm)
      return
    end if
    u_matrix = cmplx_0
    allocate (u_matrix_opt(num_bands, num_wann, num_kpts), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error in allocating u_matrix_opt in overlap_allocate', comm)
      return
    end if
    u_matrix_opt = cmplx_0

    if (timing_level > 0) call io_stopwatch_stop('overlap: allocate', timer)

  end subroutine overlap_allocate