pw90common_wanint_w90_wannier90_readwrite_dist Subroutine

public subroutine pw90common_wanint_w90_wannier90_readwrite_dist(print_output, ws_region, kmesh_info, kpt_latt, num_kpts, dis_manifold, w90_system, fermi_energy_list, num_bands, num_wann, eigval, mp_grid, real_lattice, pw90_calculation, scissors_shift, effective_model, pw90_spin, pw90_band_deriv_degen, pw90_kpath, pw90_kslice, pw90_dos, pw90_berry, pw90_spin_hall, pw90_gyrotropic, pw90_geninterp, pw90_boltzwann, eig_found, error, comm)

Uses

  • proc~~pw90common_wanint_w90_wannier90_readwrite_dist~~UsesGraph proc~pw90common_wanint_w90_wannier90_readwrite_dist pw90common_wanint_w90_wannier90_readwrite_dist module~w90_comms w90_comms proc~pw90common_wanint_w90_wannier90_readwrite_dist->module~w90_comms module~w90_constants w90_constants proc~pw90common_wanint_w90_wannier90_readwrite_dist->module~w90_constants module~w90_io w90_io proc~pw90common_wanint_w90_wannier90_readwrite_dist->module~w90_io module~w90_postw90_types w90_postw90_types proc~pw90common_wanint_w90_wannier90_readwrite_dist->module~w90_postw90_types module~w90_types w90_types proc~pw90common_wanint_w90_wannier90_readwrite_dist->module~w90_types module~w90_comms->module~w90_constants module~w90_error_base w90_error_base module~w90_comms->module~w90_error_base module~w90_io->module~w90_constants module~w90_postw90_types->module~w90_comms module~w90_postw90_types->module~w90_constants module~w90_types->module~w90_constants

distribute the parameters across processors NOTE: we only send the ones postw90 uses, not all in w90

Arguments

Type IntentOptional Attributes Name
type(print_output_type), intent(inout) :: print_output
type(ws_region_type), intent(inout) :: ws_region
type(kmesh_info_type), intent(inout) :: kmesh_info
real(kind=dp), intent(inout), allocatable :: kpt_latt(:,:)
integer, intent(inout) :: num_kpts
type(dis_manifold_type), intent(inout) :: dis_manifold
type(w90_system_type), intent(inout) :: w90_system
real(kind=dp), intent(inout), allocatable :: fermi_energy_list(:)
integer, intent(inout) :: num_bands
integer, intent(inout) :: num_wann
real(kind=dp), intent(inout), pointer :: eigval(:,:)
integer, intent(inout) :: mp_grid(3)
real(kind=dp), intent(inout) :: real_lattice(3,3)
type(pw90_calculation_type), intent(inout) :: pw90_calculation
real(kind=dp), intent(inout) :: scissors_shift
logical, intent(inout) :: effective_model
type(pw90_spin_mod_type), intent(inout) :: pw90_spin
type(pw90_band_deriv_degen_type), intent(inout) :: pw90_band_deriv_degen
type(pw90_kpath_mod_type), intent(inout) :: pw90_kpath
type(pw90_kslice_mod_type), intent(inout) :: pw90_kslice
type(pw90_dos_mod_type), intent(inout) :: pw90_dos
type(pw90_berry_mod_type), intent(inout) :: pw90_berry
type(pw90_spin_hall_type), intent(inout) :: pw90_spin_hall
type(pw90_gyrotropic_type), intent(inout) :: pw90_gyrotropic
type(pw90_geninterp_mod_type), intent(inout) :: pw90_geninterp
type(pw90_boltzwann_type), intent(inout) :: pw90_boltzwann
logical, intent(inout) :: eig_found
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~pw90common_wanint_w90_wannier90_readwrite_dist~~CallsGraph proc~pw90common_wanint_w90_wannier90_readwrite_dist pw90common_wanint_w90_wannier90_readwrite_dist interface~comms_bcast comms_bcast proc~pw90common_wanint_w90_wannier90_readwrite_dist->interface~comms_bcast proc~mpirank mpirank proc~pw90common_wanint_w90_wannier90_readwrite_dist->proc~mpirank proc~set_error_alloc set_error_alloc proc~pw90common_wanint_w90_wannier90_readwrite_dist->proc~set_error_alloc 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_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~comms_bcast_char->proc~comms_sync_error proc~comms_no_sync_bcast_char comms_no_sync_bcast_char proc~comms_bcast_char->proc~comms_no_sync_bcast_char proc~comms_bcast_cmplx->proc~comms_sync_error proc~comms_no_sync_bcast_cmplx comms_no_sync_bcast_cmplx proc~comms_bcast_cmplx->proc~comms_no_sync_bcast_cmplx proc~comms_bcast_int->proc~comms_sync_error proc~comms_no_sync_bcast_int comms_no_sync_bcast_int proc~comms_bcast_int->proc~comms_no_sync_bcast_int proc~comms_bcast_logical->proc~comms_sync_error proc~comms_no_sync_bcast_logical comms_no_sync_bcast_logical proc~comms_bcast_logical->proc~comms_no_sync_bcast_logical proc~comms_bcast_real->proc~comms_sync_error proc~comms_no_sync_bcast_real comms_no_sync_bcast_real proc~comms_bcast_real->proc~comms_no_sync_bcast_real

Source Code

  subroutine pw90common_wanint_w90_wannier90_readwrite_dist(print_output, ws_region, kmesh_info, kpt_latt, num_kpts, &
                                                            dis_manifold, w90_system, fermi_energy_list, num_bands, &
                                                            num_wann, eigval, mp_grid, real_lattice, &
                                                            pw90_calculation, scissors_shift, effective_model, &
                                                            pw90_spin, pw90_band_deriv_degen, pw90_kpath, &
                                                            pw90_kslice, pw90_dos, pw90_berry, pw90_spin_hall, &
                                                            pw90_gyrotropic, pw90_geninterp, pw90_boltzwann, &
                                                            eig_found, error, comm)
    !================================================!
    !
    !! distribute the parameters across processors
    !! NOTE: we only send the ones postw90 uses, not all in w90
    !
    !================================================!

    use w90_constants, only: dp
    use w90_io, only: io_date, io_time
    use w90_comms, only: mpirank, w90_comm_type, comms_bcast
    use w90_types
    use w90_postw90_types, only: pw90_calculation_type, pw90_spin_mod_type, &
                                 pw90_band_deriv_degen_type, pw90_kpath_mod_type, pw90_kslice_mod_type, pw90_dos_mod_type, &
                                 pw90_berry_mod_type, pw90_spin_hall_type, pw90_gyrotropic_type, pw90_geninterp_mod_type, &
                                 pw90_boltzwann_type

    type(print_output_type), intent(inout) :: print_output
    type(ws_region_type), intent(inout) :: ws_region
    type(w90_system_type), intent(inout) :: w90_system
    type(kmesh_info_type), intent(inout) :: kmesh_info
    type(dis_manifold_type), intent(inout) :: dis_manifold
    type(pw90_calculation_type), intent(inout) :: pw90_calculation
    type(pw90_spin_mod_type), intent(inout) :: pw90_spin
    type(pw90_band_deriv_degen_type), intent(inout) :: pw90_band_deriv_degen
    type(pw90_kpath_mod_type), intent(inout) :: pw90_kpath
    type(pw90_kslice_mod_type), intent(inout) :: pw90_kslice
    type(pw90_dos_mod_type), intent(inout) :: pw90_dos
    type(pw90_berry_mod_type), intent(inout) :: pw90_berry
    type(pw90_spin_hall_type), intent(inout) :: pw90_spin_hall
    type(pw90_gyrotropic_type), intent(inout) :: pw90_gyrotropic
    type(pw90_geninterp_mod_type), intent(inout) :: pw90_geninterp
    type(pw90_boltzwann_type), intent(inout) :: pw90_boltzwann
    type(w90_comm_type), intent(in) :: comm
    type(w90_error_type), allocatable, intent(out) :: error

    real(kind=dp), allocatable, intent(inout) :: kpt_latt(:, :)
    real(kind=dp), allocatable, intent(inout) :: fermi_energy_list(:)
    real(kind=dp), pointer, intent(inout) :: eigval(:, :)
    real(kind=dp), intent(inout) :: real_lattice(3, 3)
    real(kind=dp), intent(inout) :: scissors_shift
    integer, intent(inout) :: num_kpts
    integer, intent(inout) :: num_bands
    integer, intent(inout) :: num_wann
    integer, intent(inout) :: mp_grid(3)
    logical, intent(inout) :: eig_found
    logical, intent(inout) :: effective_model

    integer :: ierr
    integer :: iprintroot
    integer :: fermi_n, kdotp_nbands
    logical :: on_root = .false.

    if (mpirank(comm) == 0) on_root = .true.

    call comms_bcast(effective_model, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(eig_found, 1, error, comm)
    if (allocated(error)) return

    if (.not. effective_model) then
      call comms_bcast(mp_grid(1), 3, error, comm)
      if (allocated(error)) return
      call comms_bcast(num_kpts, 1, error, comm)
      if (allocated(error)) return
      call comms_bcast(num_bands, 1, error, comm)
      if (allocated(error)) return
    end if
    call comms_bcast(num_wann, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(print_output%timing_level, 1, error, comm)
    if (allocated(error)) return

    !______________________________________
    ! not so pretty solution to setting iprint to zero on non-root processes
    iprintroot = print_output%iprint
    print_output%iprint = 0
    call comms_bcast(print_output%iprint, 1, error, comm)
    if (allocated(error)) return
    if (on_root) print_output%iprint = iprintroot
    !______________________________________

    call comms_bcast(ws_region%ws_distance_tol, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(ws_region%ws_search_size(1), 3, error, comm)
    if (allocated(error)) return
!    call comms_bcast(num_atoms,1)   ! Ivo: not used in postw90, right?
!    call comms_bcast(num_species,1) ! Ivo: not used in postw90, right?
    call comms_bcast(real_lattice(1, 1), 9, error, comm)
    if (allocated(error)) return
    !call comms_bcast(recip_lattice(1, 1), 9, error, comm)
    !call comms_bcast(real_metric(1, 1), 9)
    !call comms_bcast(recip_metric(1, 1), 9)
    !call comms_bcast(cell_volume, 1, error, comm)
    call comms_bcast(pw90_dos%energy_step, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%smearing%use_adaptive, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%smearing%type_index, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%kmesh%spacing, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%kmesh%mesh(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%smearing%adaptive_max_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%smearing%fixed_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%smearing%adaptive_prefactor, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%num_project, 1, error, comm)
    if (allocated(error)) return

    call comms_bcast(pw90_calculation%berry, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%task, len(pw90_berry%task), error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kmesh%spacing, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kmesh%mesh(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%curv_adpt_kmesh, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%curv_adpt_kmesh_thresh, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%curv_unit, len(pw90_berry%curv_unit), error, comm)
    if (allocated(error)) return

! Tsirkin
    call comms_bcast(pw90_calculation%gyrotropic, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%task, len(pw90_gyrotropic%task), error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%kmesh%spacing, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%kmesh%mesh(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%eigval_max, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%nfreq, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%degen_thresh, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%num_bands, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%box(1, 1), 9, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%box_corner(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%smearing%use_adaptive, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%smearing%fixed_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%smearing%type_index, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%smearing%max_arg, 1, error, comm)
    if (allocated(error)) return

    call comms_bcast(w90_system%spinors, 1, error, comm)
    if (allocated(error)) return

    call comms_bcast(pw90_spin_hall%freq_scan, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin_hall%alpha, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin_hall%beta, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin_hall%gamma, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin_hall%bandshift, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin_hall%bandshift_firstband, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin_hall%bandshift_energyshift, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin_hall%method, len(pw90_spin_hall%method), error, comm)
    if (allocated(error)) return

    call comms_bcast(pw90_berry%kubo_smearing%use_adaptive, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kubo_smearing%adaptive_prefactor, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kubo_smearing%adaptive_max_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kubo_smearing%fixed_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kubo_smearing%type_index, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kubo_eigval_max, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kubo_nfreq, 1, error, comm)
    if (allocated(error)) return
    fermi_n = 0
    if (on_root) then
      if (allocated(fermi_energy_list)) fermi_n = size(fermi_energy_list)
    end if
    call comms_bcast(fermi_n, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%energy_min, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%energy_max, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin%kmesh%spacing, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin%kmesh%mesh(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%wanint_kpoint_file, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(dis_manifold%win_min, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(dis_manifold%win_max, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%sc_eta, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%sc_w_thr, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%sc_phase_conv, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%sc_use_eta_corr, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%tetrahedron_method, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%tetrahedron_higher_correction, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%tetrahedron_cutoff, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%tetrahedron_avoid_degeneracy, 1, error, comm)
    if (allocated(error)) return
! ----------------------------------------------
!
! New input variables in development
!
    !call comms_bcast(print_output%devel_flag, len(print_output%devel_flag), error, comm)
    call comms_bcast(pw90_calculation%spin_moment, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin%axis_polar, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_spin%axis_azimuth, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_calculation%spin_decomp, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_band_deriv_degen%use_degen_pert, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_band_deriv_degen%degen_thr, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(w90_system%num_valence_bands, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_calculation%dos, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%task, len(pw90_dos%task), error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_calculation%kpath, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kpath%task, len(pw90_kpath%task), error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kpath%bands_colour, len(pw90_kpath%bands_colour), error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_calculation%kslice, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kslice%task, len(pw90_kslice%task), error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kslice%corner(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kslice%b1(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kslice%b2(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kslice%kmesh2d(1), 2, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_kslice%fermi_lines_colour, len(pw90_kslice%fermi_lines_colour), error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%transl_inv, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(w90_system%num_elec_per_state, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(scissors_shift, 1, error, comm)
    if (allocated(error)) return

    ! Do these have to be broadcasted? (Plots done on root node only)
    !
!    call comms_bcast(bands_num_points,1)
!    call comms_bcast(bands_num_spec_points,1)
!    if(allocated(bands_spec_points)) &
!         call comms_bcast(bands_spec_points(1,1),3*bands_num_spec_points)
!    if(allocated(bands_label)) &
!         call comms_bcast(bands_label(:),len(bands_label(1))*bands_num_spec_points)
! ----------------------------------------------
    call comms_bcast(pw90_calculation%geninterp, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_geninterp%alsofirstder, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_geninterp%single_file, 1, error, comm)
    if (allocated(error)) return
    ! BoltzWann variables
    call comms_bcast(pw90_calculation%boltzwann, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%calc_also_dos, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dir_num_2d, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_energy_step, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_energy_min, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_energy_max, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_smearing%use_adaptive, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_smearing%fixed_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_smearing%adaptive_prefactor, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_smearing%adaptive_max_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%mu_min, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%mu_max, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%mu_step, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%temp_min, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%temp_max, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%temp_step, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%kmesh%spacing, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%kmesh%mesh(1), 3, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%tdf_energy_step, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%relax_time, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%tdf_smearing%use_adaptive, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%tdf_smearing%fixed_width, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%tdf_smearing%type_index, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%dos_smearing%type_index, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%bandshift, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%bandshift_firstband, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_boltzwann%bandshift_energyshift, 1, error, comm)
    if (allocated(error)) return
    call comms_bcast(ws_region%use_ws_distance, 1, error, comm)
    if (allocated(error)) return

    ! These variables are different from the ones above in that they are
    ! allocatable, and in w90_wannier90_readwrite_read they were allocated on the root node only

    if (.not. on_root) then
      allocate (fermi_energy_list(fermi_n), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating fermi_energy_read in postw90_w90_wannier90_readwrite_dist', comm)
        return
      end if
      allocate (pw90_berry%kubo_freq_list(pw90_berry%kubo_nfreq), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating kubo_freq_list in postw90_w90_wannier90_readwrite_dist', comm)
        return
      end if
      allocate (pw90_gyrotropic%band_list(pw90_gyrotropic%num_bands), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating gyrotropic_band_list in postw90_w90_wannier90_readwrite_dist', comm)
        return
      end if
      allocate (pw90_gyrotropic%freq_list(pw90_gyrotropic%nfreq), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating gyrotropic_freq_list in postw90_w90_wannier90_readwrite_dist', comm)
        return
      end if
      allocate (pw90_dos%project(pw90_dos%num_project), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating dos_project in postw90_w90_wannier90_readwrite_dist', comm)
        return
      end if
      if (.not. effective_model) then
        if (eig_found) then
          allocate (eigval(num_bands, num_kpts), stat=ierr)
          if (ierr /= 0) then
            call set_error_alloc(error, 'Error allocating eigval in postw90_w90_wannier90_readwrite_dist', comm)
            return
          end if
        end if
        allocate (kpt_latt(3, num_kpts), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error allocating kpt_latt in postw90_w90_wannier90_readwrite_dist', comm)
          return
        end if
      end if
    end if

    kdotp_nbands = 0
    if (on_root) then
      if (allocated(pw90_berry%kdotp_bands)) kdotp_nbands = size(pw90_berry%kdotp_bands)
    end if
    call comms_bcast(kdotp_nbands, 1, error, comm)
    if (kdotp_nbands > 0) then
      if (.not. on_root) then
        allocate (pw90_berry%kdotp_bands(kdotp_nbands), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error allocating kdotp_bands in postw90_param_dist', comm)
          return
        end if
      end if
      call comms_bcast(pw90_berry%kdotp_bands(1), kdotp_nbands, error, comm)
    end if

    if (fermi_n > 0) then
      call comms_bcast(fermi_energy_list(1), fermi_n, error, comm)
      if (allocated(error)) return
    end if
    call comms_bcast(pw90_gyrotropic%freq_list(1), pw90_gyrotropic%nfreq, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_gyrotropic%band_list(1), pw90_gyrotropic%num_bands, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_berry%kubo_freq_list(1), pw90_berry%kubo_nfreq, error, comm)
    if (allocated(error)) return
    call comms_bcast(pw90_dos%project(1), pw90_dos%num_project, error, comm)
    if (allocated(error)) return
    if (.not. effective_model) then
      if (eig_found) then
        call comms_bcast(eigval(1, 1), num_bands*num_kpts, error, comm)
        if (allocated(error)) return
      end if
      call comms_bcast(kpt_latt(1, 1), 3*num_kpts, error, comm)
      if (allocated(error)) return
    end if

    ! kmesh: only nntot,wb, and bk are needed to evaluate the WF matrix
    ! elements of the position operator in reciprocal space. For the
    ! extra matrix elements entering the orbital magnetization, also
    ! need nnlist. In principle could only broadcast those four variables

    if (.not. effective_model) then

      call comms_bcast(kmesh_info%nnh, 1, error, comm)
      if (allocated(error)) return
      call comms_bcast(kmesh_info%nntot, 1, error, comm)
      if (allocated(error)) return

      if (.not. on_root) then
        allocate (kmesh_info%nnlist(num_kpts, kmesh_info%nntot), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error in allocating nnlist in pw90common_wanint_w90_wannier90_readwrite_dist', comm)
          return
        end if
        allocate (kmesh_info%neigh(num_kpts, kmesh_info%nntot/2), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error in allocating neigh in pw90common_wanint_w90_wannier90_readwrite_dist', comm)
          return
        end if
        allocate (kmesh_info%nncell(3, num_kpts, kmesh_info%nntot), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error in allocating nncell in pw90common_wanint_w90_wannier90_readwrite_dist', comm)
          return
        end if
        allocate (kmesh_info%wb(kmesh_info%nntot), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error in allocating wb in pw90common_wanint_w90_wannier90_readwrite_dist', comm)
          return
        end if
        allocate (kmesh_info%bka(3, kmesh_info%nntot/2), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error in allocating bka in pw90common_wanint_w90_wannier90_readwrite_dist', comm)
          return
        end if
        allocate (kmesh_info%bk(3, kmesh_info%nntot, num_kpts), stat=ierr)
        if (ierr /= 0) then
          call set_error_alloc(error, 'Error in allocating bk in pw90common_wanint_w90_wannier90_readwrite_dist', comm)
          return
        end if
      end if

      call comms_bcast(kmesh_info%nnlist(1, 1), num_kpts*kmesh_info%nntot, error, comm)
      if (allocated(error)) return
      call comms_bcast(kmesh_info%neigh(1, 1), num_kpts*kmesh_info%nntot/2, error, comm)
      if (allocated(error)) return
      call comms_bcast(kmesh_info%nncell(1, 1, 1), 3*num_kpts*kmesh_info%nntot, error, comm)
      if (allocated(error)) return
      call comms_bcast(kmesh_info%wb(1), kmesh_info%nntot, error, comm)
      if (allocated(error)) return
      call comms_bcast(kmesh_info%bka(1, 1), 3*kmesh_info%nntot/2, error, comm)
      if (allocated(error)) return
      call comms_bcast(kmesh_info%bk(1, 1, 1), 3*kmesh_info%nntot*num_kpts, error, comm)
      if (allocated(error)) return

    end if

  end subroutine pw90common_wanint_w90_wannier90_readwrite_dist