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!
| Type | Intent | Optional | 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 |
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