read_chkpt Subroutine

public subroutine read_chkpt(common_data, checkpoint, istdout, istderr, ierr)

Uses

  • proc~~read_chkpt~~UsesGraph proc~read_chkpt read_chkpt module~w90_comms w90_comms proc~read_chkpt->module~w90_comms module~w90_error w90_error proc~read_chkpt->module~w90_error module~w90_error_base w90_error_base proc~read_chkpt->module~w90_error_base module~w90_readwrite w90_readwrite proc~read_chkpt->module~w90_readwrite module~w90_comms->module~w90_error_base module~w90_constants w90_constants module~w90_comms->module~w90_constants module~w90_error->module~w90_comms module~w90_error->module~w90_error_base module~w90_readwrite->module~w90_comms module~w90_readwrite->module~w90_constants module~w90_types w90_types module~w90_readwrite->module~w90_types module~w90_types->module~w90_constants

Arguments

Type IntentOptional Attributes Name
type(lib_common_type), intent(inout), target :: common_data
character(len=20), intent(out) :: checkpoint
integer, intent(in) :: istdout
integer, intent(in) :: istderr
integer, intent(out) :: ierr

Calls

proc~~read_chkpt~~CallsGraph proc~read_chkpt read_chkpt proc~mpirank mpirank proc~read_chkpt->proc~mpirank proc~prterr prterr proc~read_chkpt->proc~prterr proc~set_error_alloc set_error_alloc proc~read_chkpt->proc~set_error_alloc proc~w90_readwrite_chkpt_dist w90_readwrite_chkpt_dist proc~read_chkpt->proc~w90_readwrite_chkpt_dist proc~w90_readwrite_read_chkpt w90_readwrite_read_chkpt proc~read_chkpt->proc~w90_readwrite_read_chkpt proc~prterr->proc~mpirank interface~comms_no_sync_bcast comms_no_sync_bcast proc~prterr->interface~comms_no_sync_bcast interface~comms_no_sync_recv comms_no_sync_recv proc~prterr->interface~comms_no_sync_recv interface~comms_no_sync_send comms_no_sync_send proc~prterr->interface~comms_no_sync_send proc~mpisize mpisize proc~prterr->proc~mpisize 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~w90_readwrite_chkpt_dist->proc~mpirank proc~w90_readwrite_chkpt_dist->proc~set_error_alloc interface~comms_bcast comms_bcast proc~w90_readwrite_chkpt_dist->interface~comms_bcast proc~w90_readwrite_read_chkpt_header w90_readwrite_read_chkpt_header proc~w90_readwrite_read_chkpt->proc~w90_readwrite_read_chkpt_header proc~w90_readwrite_read_chkpt_matrices w90_readwrite_read_chkpt_matrices proc~w90_readwrite_read_chkpt->proc~w90_readwrite_read_chkpt_matrices proc~comms_bcast_char comms_bcast_char interface~comms_bcast->proc~comms_bcast_char proc~comms_bcast_cmplx comms_bcast_cmplx interface~comms_bcast->proc~comms_bcast_cmplx proc~comms_bcast_int comms_bcast_int interface~comms_bcast->proc~comms_bcast_int proc~comms_bcast_logical comms_bcast_logical interface~comms_bcast->proc~comms_bcast_logical proc~comms_bcast_real comms_bcast_real interface~comms_bcast->proc~comms_bcast_real proc~comms_no_sync_bcast_char comms_no_sync_bcast_char interface~comms_no_sync_bcast->proc~comms_no_sync_bcast_char proc~comms_no_sync_bcast_cmplx comms_no_sync_bcast_cmplx interface~comms_no_sync_bcast->proc~comms_no_sync_bcast_cmplx proc~comms_no_sync_bcast_int comms_no_sync_bcast_int interface~comms_no_sync_bcast->proc~comms_no_sync_bcast_int proc~comms_no_sync_bcast_logical comms_no_sync_bcast_logical interface~comms_no_sync_bcast->proc~comms_no_sync_bcast_logical proc~comms_no_sync_bcast_real comms_no_sync_bcast_real interface~comms_no_sync_bcast->proc~comms_no_sync_bcast_real proc~comms_no_sync_recv_char comms_no_sync_recv_char interface~comms_no_sync_recv->proc~comms_no_sync_recv_char proc~comms_no_sync_recv_cmplx comms_no_sync_recv_cmplx interface~comms_no_sync_recv->proc~comms_no_sync_recv_cmplx proc~comms_no_sync_recv_int comms_no_sync_recv_int interface~comms_no_sync_recv->proc~comms_no_sync_recv_int proc~comms_no_sync_recv_logical comms_no_sync_recv_logical interface~comms_no_sync_recv->proc~comms_no_sync_recv_logical proc~comms_no_sync_recv_real comms_no_sync_recv_real interface~comms_no_sync_recv->proc~comms_no_sync_recv_real proc~comms_no_sync_send_char comms_no_sync_send_char interface~comms_no_sync_send->proc~comms_no_sync_send_char proc~comms_no_sync_send_cmplx comms_no_sync_send_cmplx interface~comms_no_sync_send->proc~comms_no_sync_send_cmplx proc~comms_no_sync_send_int comms_no_sync_send_int interface~comms_no_sync_send->proc~comms_no_sync_send_int proc~comms_no_sync_send_logical comms_no_sync_send_logical interface~comms_no_sync_send->proc~comms_no_sync_send_logical proc~comms_no_sync_send_real comms_no_sync_send_real interface~comms_no_sync_send->proc~comms_no_sync_send_real 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~w90_readwrite_read_chkpt_matrices->proc~mpirank proc~w90_readwrite_read_chkpt_matrices->proc~set_error_alloc proc~w90_readwrite_read_chkpt_matrices->proc~set_error_file proc~comms_bcast_char->proc~comms_sync_error proc~comms_bcast_char->proc~comms_no_sync_bcast_char proc~comms_bcast_cmplx->proc~comms_sync_error proc~comms_bcast_cmplx->proc~comms_no_sync_bcast_cmplx proc~comms_bcast_int->proc~comms_sync_error proc~comms_bcast_int->proc~comms_no_sync_bcast_int proc~comms_bcast_logical->proc~comms_sync_error proc~comms_bcast_logical->proc~comms_no_sync_bcast_logical proc~comms_bcast_real->proc~comms_sync_error proc~comms_bcast_real->proc~comms_no_sync_bcast_real proc~set_error_file->proc~comms_sync_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~~read_chkpt~~CalledByGraph proc~read_chkpt read_chkpt program~wannier wannier program~wannier->proc~read_chkpt

Source Code

  subroutine read_chkpt(common_data, checkpoint, istdout, istderr, ierr)
    use w90_comms, only: mpirank
    use w90_error_base, only: w90_error_type
    use w90_error, only: set_error_alloc, set_error_dealloc
    use w90_readwrite, only: w90_readwrite_read_chkpt, w90_readwrite_chkpt_dist

    implicit none

    ! arguments
    character(len=20), intent(out) :: checkpoint
    integer, intent(in) :: istdout, istderr
    integer, intent(out) :: ierr
    type(lib_common_type), target, intent(inout) :: common_data

    ! local variables
    complex(kind=dp), allocatable :: m(:, :, :, :)
    integer, pointer :: nw, nb, nk, nn
    integer :: rank, nexclude = 0, istat
    logical :: ispostw90 = .false. ! ispostw90 is used to print a different error message in case the chk file is missing (did you run w90 first?)
    type(w90_error_type), allocatable :: error

    ierr = 0
    rank = mpirank(common_data%comm)

    nb => common_data%num_bands
    nk => common_data%num_kpts
    nn => common_data%kmesh_info%nntot
    nw => common_data%num_wann

    ! allocating and partially assigning the full matrix on all ranks and reducing is a terrible idea at scale
    ! alternatively, allocate on root and use point-to-point
    ! or, if required only for checkpoint file writing, then use mpi-io (but needs to be ordered io, alas)
    ! or, even better, use parallel hdf5
    allocate (m(nw, nw, nn, nk), stat=istat) ! all kpts
    if (istat /= 0) then
      call set_error_alloc(error, 'Error allocating m in read_chkpt', common_data%comm)
      call prterr(error, ierr, istdout, istderr, common_data%comm)
      return
    end if

    if (rank == 0) then
      if (allocated(common_data%exclude_bands)) nexclude = size(common_data%exclude_bands)

      call w90_readwrite_read_chkpt(common_data%dis_manifold, common_data%exclude_bands, &
                                    common_data%kmesh_info, common_data%kpt_latt, &
                                    common_data%wannier_data, m, common_data%u_matrix, &
                                    common_data%u_matrix_opt, common_data%real_lattice, &
                                    common_data%omega%invariant, common_data%mp_grid, nb, &
                                    nexclude, nk, nw, checkpoint, common_data%have_disentangled, &
                                    ispostw90, common_data%seedname, istdout, error, &
                                    common_data%comm)
      if (allocated(error)) then
        call prterr(error, ierr, istdout, istderr, common_data%comm)
        return
      end if
    end if

    ! scatter from m_matrix to m_matrix_local (cf overlap_read)
    call w90_readwrite_chkpt_dist(common_data%dis_manifold, common_data%wannier_data, &
                                  common_data%u_matrix, common_data%u_matrix_opt, m, &
                                  common_data%m_matrix_local, common_data%omega%invariant, &
                                  nb, nk, nw, nn, checkpoint, common_data%have_disentangled, &
                                  common_data%dist_kpoints, error, common_data%comm)
    if (allocated(error)) then
      call prterr(error, ierr, istdout, istderr, common_data%comm)
      return
    end if

    deallocate (m, stat=istat)
    if (istat /= 0) then
      call set_error_alloc(error, 'Error deallocating m in read_chkpt', common_data%comm)
      call prterr(error, ierr, istdout, istderr, common_data%comm)
      return
    end if
  end subroutine read_chkpt