subroutine w90_readwrite_clear_keywords(settings, error, comm)
! wannier90.x and postw90.x each read only their own subset of the valid tokens in the .win file;
! the file is validated by checking that nothing remains in the input stream once every valid
! token has been removed. This routine removes the tokens of the other program by reading them
! into nothing: the w90_readwrite_get_* readers assign only to optional arguments and clear the
! matched lines from the stream as a side effect. A token found more than once is an input
! error and is reported as such, not as an unrecognised keyword.
!
! The lists below are the union of wannier90.x and postw90.x tokens and are maintained by hand.
use w90_error, only: w90_error_type, set_error_dealloc, set_error_alloc
implicit none
type(w90_comm_type), intent(in) :: comm
type(settings_type), intent(inout) :: settings
type(w90_error_type), allocatable, intent(out) :: error
character(len=*), parameter :: blocks(*) = [character(len=32) :: &
'atoms_cart', 'atoms_frac', 'dis_spheres', 'kpoint_path', 'kpoints', &
'explicit_kpath_labels', 'explicit_kpath', 'nnkpts', 'projections', 'slwf_centres', &
'unit_cell_cart']
character(len=*), parameter :: keywords(*) = [character(len=32) :: &
'auto_projections', 'bands_num_points', 'bands_plot_dim', 'bands_plot_format', &
'bands_plot', 'bands_plot_mode', 'calc_only_A', 'conv_noise_amp', 'conv_noise_num', &
'conv_tol', 'conv_window', 'cp_pp', 'devel_flag', 'dis_conv_tol', 'dis_conv_window', &
'dis_froz_max', 'dis_froz_min', 'dis_froz_proj', 'dis_proj_min', 'dis_proj_max', &
'dis_proj_auto', 'dis_proj_auto_num_classes', 'dis_mix_ratio', 'dis_num_iter', &
'dis_spheres_first_wann', 'dis_spheres_num', 'dist_cutoff', 'dist_cutoff_hc', &
'dist_cutoff_mode', 'dis_win_max', 'dis_win_min', 'energy_unit', 'fermi_energy', &
'fermi_energy_max', 'fermi_energy_min', 'fermi_energy_step', 'fermi_surface_num_points', &
'fermi_surface_plot_format', 'fermi_surface_plot', 'fixed_step', 'gamma_only', &
'guiding_centres', 'higher_order_n', 'higher_order_nearest_shells', 'hr_cutoff', 'hr_plot', &
'iprint', 'kmesh_spacing', 'kmesh_tol', 'length_unit', 'num_bands', 'num_cg_steps', &
'num_dump_cycles', 'num_elec_per_state', 'num_guide_cycles', 'num_iter', &
'num_no_guide_iter', 'num_print_cycles', 'num_shells', 'num_valence_bands', 'num_wann', &
'use_ss_functional', 'one_dim_axis', 'optimisation', 'postproc_setup', 'precond', &
'restart', 'search_shells', 'search_supcell_size', 'site_symmetry', 'skip_b1_tests', &
'slwf_constrain', 'slwf_lambda', 'slwf_num', 'spin', 'spinors', 'symmetrize_eps', 'timing_level', &
'total_bands', 'tran_easy_fix', 'tran_energy_step', 'tran_group_threshold', &
'tran_num_bandc', 'tran_num_bb', 'tran_num_cc', 'tran_num_cell_ll', 'tran_num_cell_rr', &
'tran_num_cr', 'tran_num_lc', 'tran_num_ll', 'tran_num_rr', 'tran_read_ht', &
'translate_home_cell', 'transport', 'transport_mode', 'tran_use_same_lead', 'tran_win_max', &
'tran_win_min', 'tran_write_ht', 'trial_step', 'unlucky', 'use_bloch_phases', &
'use_ws_distance', 'wannier_plot_format', 'wannier_plot', 'wannier_plot_mode', &
'wannier_plot_radius', 'wannier_plot_scale', 'wannier_plot_spinor_mode', &
'wannier_plot_spinor_phase', 'write_bvec', 'write_hr_diag', 'write_hr', 'write_proj', &
'write_r2mn', 'write_rmn', 'write_tb', 'write_u_matrices', 'write_vdw_data', 'write_xyz', &
'ws_distance_tol', 'wvfn_formatted', 'adpt_smr_fac', 'adpt_smr', 'adpt_smr_max', &
'berry_curv_adpt_kmesh', 'berry_curv_adpt_kmesh_thresh', 'berry_curv_unit', 'berry', &
'berry_kmesh_spacing', 'berry_task', 'boltz_2d_dir', 'boltz_bandshift_energyshift', &
'boltz_bandshift_firstband', 'boltz_bandshift', 'boltz_calc_also_dos', &
'boltz_dos_adpt_smr_fac', 'boltz_dos_adpt_smr', 'boltz_dos_adpt_smr_max', &
'boltz_dos_energy_max', 'boltz_dos_energy_min', 'boltz_dos_energy_step', &
'boltz_dos_smr_fixed_en_width', 'boltz_dos_smr_type', 'boltz_kmesh_spacing', &
'boltz_mu_max', 'boltz_mu_min', 'boltz_mu_step', 'boltz_relax_time', &
'boltz_tdf_energy_step', 'boltz_tdf_smr_fixed_en_width', 'boltz_tdf_smr_type', &
'boltz_temp_max', 'boltz_temp_min', 'boltz_temp_step', 'boltzwann', 'degen_thr', &
'dos_adpt_smr_fac', 'dos_adpt_smr', 'dos_adpt_smr_max', 'dos_energy_max', 'dos_energy_min', &
'dos_energy_step', 'dos', 'dos_kmesh_spacing', 'dos_smr_fixed_en_width', 'dos_smr_type', &
'dos_task', 'effective_model', 'geninterp_alsofirstder', 'geninterp', &
'geninterp_single_file', 'gyrotropic_degen_thresh', 'gyrotropic_eigval_max', 'gyrotropic', &
'gyrotropic_freq_max', 'gyrotropic_freq_min', 'gyrotropic_freq_step', &
'gyrotropic_kmesh_spacing', 'gyrotropic_smr_fixed_en_width', 'gyrotropic_smr_max_arg', &
'gyrotropic_smr_type', 'gyrotropic_task', 'kpath_bands_colour', 'kpath', &
'kpath_num_points', 'kpath_task', 'kslice_fermi_lines_colour', 'kslice', 'kslice_task', &
'kdotp_num_bands', 'kubo_adpt_smr_fac', 'kubo_adpt_smr', 'kubo_adpt_smr_max', &
'kubo_eigval_max', 'kubo_freq_max', 'kubo_freq_min', 'kubo_freq_step', &
'kubo_smr_fixed_en_width', 'kubo_smr_type', 'sc_eta', 'scissors_shift', 'sc_phase_conv', &
'sc_use_eta_corr', 'sc_w_thr', 'shc_alpha', 'shc_bandshift_energyshift', &
'shc_bandshift_firstband', 'shc_bandshift', 'shc_beta', 'shc_freq_scan', 'shc_gamma', &
'shc_method', 'smr_fixed_en_width', 'smr_max_arg', 'smr_type', 'spin_axis_azimuth', &
'spin_axis_polar', 'spin_decomp', 'spin_kmesh_spacing', 'spin_moment', 'spn_formatted', &
'tetrahedron_avoid_degeneracy', 'tetrahedron_correction', 'tetrahedron_cutoff', &
'tetrahedron_higher_correction', 'tetrahedron_method', 'transl_inv', 'transl_inv_full', &
'uhu_formatted', 'use_degen_pert', 'wanint_kpoint_file', 'kmesh_shell_from_file']
character(len=*), parameter :: vectors(*) = [character(len=32) :: &
'kmesh', 'mp_grid', 'translation_centre_frac', 'wannier_plot_supercell', 'ws_search_size', &
'berry_kmesh', 'boltz_kmesh', 'dos_kmesh', 'gyrotropic_box_b1', 'gyrotropic_box_b2', &
'gyrotropic_box_b3', 'gyrotropic_box_center', 'gyrotropic_kmesh', 'kdotp_kpoint', &
'kslice_2dkmesh', 'kslice_b1', 'kslice_b2', 'kslice_corner', 'spin_kmesh']
character(len=*), parameter :: ranges(*) = [character(len=32) :: &
'bands_plot_project', 'wannier_plot_list', 'select_projections', 'shell_list', &
'exclude_bands', 'gyrotropic_band_list', 'kdotp_bands', 'dos_project']
logical :: found
integer :: i, lx, ierr
integer, allocatable :: lxa(:)
do i = 1, size(blocks)
call clear_block(settings, trim(blocks(i)), error, comm)
if (allocated(error)) return
end do
do i = 1, size(keywords)
call w90_readwrite_get_keyword(settings, trim(keywords(i)), found, error, comm)
if (allocated(error)) return
end do
do i = 1, size(vectors)
call w90_readwrite_get_keyword_vector(settings, trim(vectors(i)), found, 0, error, comm)
if (allocated(error)) return
end do
do i = 1, size(ranges)
! the counting pass leaves the line in the stream; a second pass with a target consumes it
call w90_readwrite_get_range_vector(settings, trim(ranges(i)), found, lx, .true., error, comm)
if (allocated(error)) return
if (.not. found) cycle
allocate (lxa(lx), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error in allocating lxa in w90_readwrite_clear_keywords', comm)
return
end if
call w90_readwrite_get_range_vector(settings, trim(ranges(i)), found, lx, .false., error, comm, lxa)
if (allocated(error)) return
deallocate (lxa, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error in deallocating lxa in w90_readwrite_clear_keywords', comm)
return
end if
end do
end subroutine w90_readwrite_clear_keywords