w90_readwrite_read_chkpt_header Subroutine

public subroutine w90_readwrite_read_chkpt_header(exclude_bands, kmesh_info, kpt_latt, real_lattice, mp_grid, num_bands, num_exclude_bands, num_kpts, num_wann, checkpoint, have_disentangled, ispostw90, seedname, chk_unit, stdout, error, comm)

Uses

  • proc~~w90_readwrite_read_chkpt_header~~UsesGraph proc~w90_readwrite_read_chkpt_header w90_readwrite_read_chkpt_header module~w90_comms w90_comms proc~w90_readwrite_read_chkpt_header->module~w90_comms module~w90_constants w90_constants proc~w90_readwrite_read_chkpt_header->module~w90_constants module~w90_error w90_error proc~w90_readwrite_read_chkpt_header->module~w90_error module~w90_utility w90_utility proc~w90_readwrite_read_chkpt_header->module~w90_utility 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
integer, intent(inout), allocatable :: exclude_bands(:)
type(kmesh_info_type), intent(in) :: kmesh_info
real(kind=dp), intent(in) :: kpt_latt(:,:)
real(kind=dp), intent(in) :: real_lattice(3,3)
integer, intent(in) :: mp_grid(3)
integer, intent(in) :: num_bands
integer, intent(in) :: num_exclude_bands
integer, intent(in) :: num_kpts
integer, intent(in) :: num_wann
character(len=20), intent(inout) :: checkpoint
logical, intent(out) :: have_disentangled
logical, intent(in) :: ispostw90
character(len=*), intent(in) :: seedname
integer, intent(inout) :: 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_header~~CallsGraph proc~w90_readwrite_read_chkpt_header w90_readwrite_read_chkpt_header proc~mpirank mpirank proc~w90_readwrite_read_chkpt_header->proc~mpirank proc~set_error_file set_error_file proc~w90_readwrite_read_chkpt_header->proc~set_error_file proc~utility_recip_lattice utility_recip_lattice proc~w90_readwrite_read_chkpt_header->proc~utility_recip_lattice proc~comms_sync_error comms_sync_error proc~set_error_file->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_file->proc~set_base_error proc~set_error_fatal set_error_fatal proc~utility_recip_lattice->proc~set_error_fatal proc~utility_recip_lattice_base utility_recip_lattice_base proc~utility_recip_lattice->proc~utility_recip_lattice_base proc~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error proc~utility_inv3 utility_inv3 proc~utility_recip_lattice_base->proc~utility_inv3

Called by

proc~~w90_readwrite_read_chkpt_header~~CalledByGraph proc~w90_readwrite_read_chkpt_header w90_readwrite_read_chkpt_header proc~w90_readwrite_read_chkpt w90_readwrite_read_chkpt proc~w90_readwrite_read_chkpt->proc~w90_readwrite_read_chkpt_header 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_header(exclude_bands, kmesh_info, kpt_latt, real_lattice, &
                                             mp_grid, num_bands, num_exclude_bands, num_kpts, &
                                             num_wann, checkpoint, have_disentangled, ispostw90, &
                                             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_constants, only: eps6
    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

    integer, allocatable, intent(inout) :: exclude_bands(:)
    type(kmesh_info_type), intent(in) :: kmesh_info
    real(kind=dp), intent(in) :: kpt_latt(:, :)
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    integer, intent(in) :: num_kpts
    integer, intent(in) :: num_bands
    integer, intent(in) :: num_wann
    integer, intent(in) :: stdout
    integer, intent(in) :: mp_grid(3)
    integer, intent(in) :: num_exclude_bands
    integer, intent(inout) :: chk_unit

    real(kind=dp), intent(in) :: real_lattice(3, 3)

    character(len=*), intent(in)  :: seedname
    character(len=20), intent(inout) :: checkpoint

    logical, intent(in) :: ispostw90 ! Are we running postw90?
    logical, intent(out) :: have_disentangled

    ! local variables
    real(kind=dp) :: recip_lattice(3, 3), volume
    integer :: nkp, i, j, ntmp, stat
    character(len=33) :: header
    real(kind=dp) :: tmp_latt(3, 3), tmp_kpt_latt(3, num_kpts)
    integer :: tmp_excl_bands(1:num_exclude_bands), tmp_mp_grid(1:3)
    logical :: on_root

    on_root = (mpirank(comm) == 0)

    if (on_root) write (stdout, '(1x,3a)') 'Reading restart information from file ', trim(seedname), '.chk :'

    open (newunit=chk_unit, file=trim(seedname)//'.chk', status='old', form='unformatted', err=121)

    ! Read comment line
    read (chk_unit) header
    if (on_root) write (stdout, '(1x,a)', advance='no') trim(header)

    ! Consistency checks
    read (chk_unit) ntmp                           ! Number of bands
    if (ntmp .ne. num_bands) then
      call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in num_bands', comm)
      return
    end if
    read (chk_unit) ntmp                           ! Number of excluded bands
    if (ntmp .ne. num_exclude_bands) then
      call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in num_exclude_bands', comm)
      return
    end if
    read (chk_unit) (tmp_excl_bands(i), i=1, num_exclude_bands) ! Excluded bands
    do i = 1, num_exclude_bands
      if (tmp_excl_bands(i) .ne. exclude_bands(i)) then
        call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in exclude_bands', comm)
        return
      end if
    end do
    read (chk_unit) ((tmp_latt(i, j), i=1, 3), j=1, 3)  ! Real lattice
    do j = 1, 3
      do i = 1, 3
        if (abs(tmp_latt(i, j) - real_lattice(i, j)) .gt. eps6) then
          call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in real_lattice', comm)
          return
        end if
      end do
    end do
    call utility_recip_lattice(real_lattice, recip_lattice, volume, error, comm)
    read (chk_unit) ((tmp_latt(i, j), i=1, 3), j=1, 3)  ! Reciprocal lattice
    do j = 1, 3
      do i = 1, 3
        if (abs(tmp_latt(i, j) - recip_lattice(i, j)) .gt. eps6) then
          call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in recip_lattice', comm)
          return
        end if
      end do
    end do
    read (chk_unit) ntmp                ! K-points
    if (ntmp .ne. num_kpts) then
      call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in num_kpts', comm)
      return
    end if
    read (chk_unit) (tmp_mp_grid(i), i=1, 3)         ! M-P grid
    do i = 1, 3
      if (tmp_mp_grid(i) .ne. mp_grid(i)) then
        call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in mp_grid', comm)
        return
      end if
    end do
    read (chk_unit) ((tmp_kpt_latt(i, nkp), i=1, 3), nkp=1, num_kpts)
    do nkp = 1, num_kpts
      do i = 1, 3
        if (abs(tmp_kpt_latt(i, nkp) - kpt_latt(i, nkp)) .gt. eps6) then
          call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in kpt_latt', comm)
          return
        end if
      end do
    end do
    read (chk_unit) ntmp                ! nntot
    if (ntmp .ne. kmesh_info%nntot) then
      call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in nntot', comm)
      return
    end if
    read (chk_unit) ntmp                ! num_wann
    if (ntmp .ne. num_wann) then
      call set_error_file(error, 'w90_readwrite_read_chk: Mismatch in num_wann', comm)
      return
    end if
    ! End of consistency checks

    read (chk_unit) checkpoint             ! checkpoint
    checkpoint = adjustl(trim(checkpoint))

    read (chk_unit) have_disentangled      ! whether a disentanglement has been performed

    return

121 if (ispostw90) then
      call set_error_file(error, 'Error opening '//trim(seedname) &
                          //'.chk in w90_readwrite_read_chkpt: did you run wannier90.x first?', comm)
    else
      call set_error_file(error, 'Error opening '//trim(seedname)//'.chk in w90_readwrite_read_chkpt', comm)
    end if
  end subroutine w90_readwrite_read_chkpt_header