w90_readwrite_read_chkpt_matrices Subroutine

public subroutine w90_readwrite_read_chkpt_matrices(dis_manifold, kmesh_info, wannier_data, m_matrix, u_matrix, u_matrix_opt, omega_invariant, num_bands, num_kpts, num_wann, have_disentangled, seedname, chk_unit, stdout, error, comm)

Uses

  • proc~~w90_readwrite_read_chkpt_matrices~~UsesGraph proc~w90_readwrite_read_chkpt_matrices w90_readwrite_read_chkpt_matrices module~w90_comms w90_comms proc~w90_readwrite_read_chkpt_matrices->module~w90_comms module~w90_error w90_error proc~w90_readwrite_read_chkpt_matrices->module~w90_error module~w90_utility w90_utility proc~w90_readwrite_read_chkpt_matrices->module~w90_utility module~w90_constants w90_constants 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_utility->module~w90_comms module~w90_utility->module~w90_constants

Read checkpoint file IMPORTANT! If you change the chkpt format, adapt accordingly also the w90chk2chk.x utility!

Note on parallelization: this function should be called from the root node only!

Arguments

Type IntentOptional Attributes Name
type(dis_manifold_type), intent(inout) :: dis_manifold
type(kmesh_info_type), intent(in) :: kmesh_info
type(wannier_data_type), intent(inout) :: wannier_data
complex(kind=dp), intent(inout) :: m_matrix(:,:,:,:)
complex(kind=dp), intent(inout) :: u_matrix(:,:,:)
complex(kind=dp), intent(inout) :: u_matrix_opt(:,:,:)
real(kind=dp), intent(inout) :: omega_invariant
integer, intent(in) :: num_bands
integer, intent(in) :: num_kpts
integer, intent(in) :: num_wann
logical, intent(in) :: have_disentangled
character(len=*), intent(in) :: seedname
integer, intent(in) :: chk_unit
integer, intent(in) :: stdout
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_read_chkpt_matrices~~CallsGraph proc~w90_readwrite_read_chkpt_matrices w90_readwrite_read_chkpt_matrices proc~mpirank mpirank proc~w90_readwrite_read_chkpt_matrices->proc~mpirank proc~set_error_alloc set_error_alloc proc~w90_readwrite_read_chkpt_matrices->proc~set_error_alloc proc~set_error_file set_error_file proc~w90_readwrite_read_chkpt_matrices->proc~set_error_file 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~set_error_file->proc~comms_sync_error proc~set_error_file->proc~set_base_error

Called by

proc~~w90_readwrite_read_chkpt_matrices~~CalledByGraph proc~w90_readwrite_read_chkpt_matrices w90_readwrite_read_chkpt_matrices proc~w90_readwrite_read_chkpt w90_readwrite_read_chkpt proc~w90_readwrite_read_chkpt->proc~w90_readwrite_read_chkpt_matrices proc~read_chkpt read_chkpt proc~read_chkpt->proc~w90_readwrite_read_chkpt program~postw90 postw90 program~postw90->proc~w90_readwrite_read_chkpt program~wannier wannier program~wannier->proc~read_chkpt

Source Code

  subroutine w90_readwrite_read_chkpt_matrices(dis_manifold, kmesh_info, wannier_data, m_matrix, &
                                               u_matrix, u_matrix_opt, omega_invariant, num_bands, &
                                               num_kpts, num_wann, have_disentangled, seedname, &
                                               chk_unit, stdout, error, comm)
    !================================================!
    !! Read checkpoint file
    !! IMPORTANT! If you change the chkpt format, adapt
    !! accordingly also the w90chk2chk.x utility!
    !!
    !! Note on parallelization: this function should be called
    !! from the root node only!
    !!
    !================================================!

    use w90_comms, only: mpirank
    use w90_error, only: w90_error_type, set_error_file, set_error_file, set_error_alloc
    use w90_utility, only: utility_recip_lattice

    implicit none

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

    integer, intent(in) :: num_kpts
    integer, intent(in) :: num_bands
    integer, intent(in) :: num_wann
    integer, intent(in) :: stdout, chk_unit

    complex(kind=dp), intent(inout) :: u_matrix(:, :, :)
    complex(kind=dp), intent(inout) :: u_matrix_opt(:, :, :)
    complex(kind=dp), intent(inout) :: m_matrix(:, :, :, :)

    real(kind=dp), intent(inout) :: omega_invariant

    character(len=*), intent(in)  :: seedname

    logical, intent(in) :: have_disentangled

    ! local variables
    integer :: nkp, i, j, k, l, ierr, stat

    if (have_disentangled) then

      read (chk_unit) omega_invariant     ! omega invariant

      ! lwindow
      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_read_chkpt_matrices', comm)
          return
        end if
      end if
      read (chk_unit, err=122) ((dis_manifold%lwindow(i, nkp), i=1, num_bands), nkp=1, num_kpts)

      ! ndimwin
      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_read_chkpt_matrices', comm)
          return
        end if
      end if
      read (chk_unit, err=123) (dis_manifold%ndimwin(nkp), nkp=1, num_kpts)

      ! U_matrix_opt
      read (chk_unit, err=124) (((u_matrix_opt(i, j, nkp), i=1, num_bands), j=1, num_wann), nkp=1, num_kpts)

    else
      ! if not read, u_matrix_opt must be explicitly zeroed
      u_matrix_opt(:, :, :) = 0
    end if

    ! U_matrix
    read (chk_unit, err=125) (((u_matrix(i, j, k), i=1, num_wann), j=1, num_wann), k=1, num_kpts)

    ! M_matrix
    read (chk_unit, err=126) &
      ((((m_matrix(i, j, k, l), i=1, num_wann), j=1, num_wann), k=1, kmesh_info%nntot), l=1, num_kpts)

    ! wannier_centres
    read (chk_unit, err=127) ((wannier_data%centres(i, j), i=1, 3), j=1, num_wann)

    ! wannier spreads
    read (chk_unit, err=128) (wannier_data%spreads(i), i=1, num_wann)

    close (chk_unit)

    if (mpirank(comm) == 0) write (stdout, '(a/)') ' ... done'

    return

122 call set_error_file(error, 'Error reading lwindow from '//trim(seedname)//'.chk in  &
     & w90_readwrite_read_chkpt_matrices', comm)
    return
123 call set_error_file(error, 'Error reading ndimwin from '//trim(seedname)//'.chk in &
     & w90_readwrite_read_chkpt_matrices', comm)
    return
124 call set_error_file(error, 'Error reading u_matrix_opt from '//trim(seedname)//'.chk in &
    & w90_readwrite_read_chkpt_matrices', comm)
    return
125 call set_error_file(error, 'Error reading u_matrix from '//trim(seedname)//'.chk in &
    & w90_readwrite_read_chkpt_matrices', comm)
    return
126 call set_error_file(error, 'Error reading m_matrix from '//trim(seedname)//'.chk in &
    & w90_readwrite_read_chkpt_matrices', comm)
    return
127 call set_error_file(error, 'Error reading wannier_centres from '//trim(seedname)//'.chk in &
    & w90_readwrite_read_chkpt_matrices', comm)
    return
128 call set_error_file(error, 'Error reading wannier_spreads from '//trim(seedname)//'.chk in &
    & w90_readwrite_read_chkpt_matrices', comm)
    return
  end subroutine w90_readwrite_read_chkpt_matrices