! Generated by tools/generate_config_layout.py; edit beach/config/_layout.py.
module bem_config_layout_paths
  implicit none
  private
  public :: reader_layout_path, grouped_layout_table
contains
  !> Return the existing reader path for one grouped setting.
  function reader_layout_path(path) result(reader_path)
    character(len=*), intent(in) :: path
    character(len=:), allocatable :: reader_path
    select case (path)
    case ('particles.tracking.dt_s')
      reader_path = 'sim.dt'
    case ('particles.tracking.max_steps_per_particle')
      reader_path = 'sim.max_step'
    case ('particles.tracking.substep_field_change_max')
      reader_path = 'sim.substep_field_change_max'
    case ('particles.tracking.substep_max_halvings')
      reader_path = 'sim.substep_max_halvings'
    case ('particles.tracking.step_growth')
      reader_path = 'sim.step_growth'
    case ('particles.tracking.step_growth_max')
      reader_path = 'sim.step_growth_max'
    case ('particles.tracking.step_growth_energy_fraction')
      reader_path = 'sim.step_growth_energy_fraction'
    case ('run.rng_seed')
      reader_path = 'sim.rng_seed'
    case ('run.batch_count')
      reader_path = 'sim.batch_count'
    case ('run.batch.duration_s')
      reader_path = 'sim.batch_duration'
    case ('run.batch.duration_steps')
      reader_path = 'sim.batch_duration_step'
    case ('run.batch.particle_distribution')
      reader_path = 'sim.particle_distribution'
    case ('run.batch.particle_pool_chunk')
      reader_path = 'sim.particle_pool_chunk'
    case ('output.diagnostics.charge_rel_change_threshold')
      reader_path = 'sim.tol_rel'
    case ('output.diagnostics.charge_floor_c')
      reader_path = 'sim.q_floor'
    case ('fields.solver.method')
      reader_path = 'sim.field_solver'
    case ('fields.solver.normalization')
      reader_path = 'sim.field_normalization'
    case ('fields.solver.length_scale_m')
      reader_path = 'sim.field_length_scale'
    case ('fields.solver.tree.theta')
      reader_path = 'sim.tree_theta'
    case ('fields.solver.tree.leaf_max')
      reader_path = 'sim.tree_leaf_max'
    case ('fields.solver.auto_fmm_min_elements')
      reader_path = 'sim.tree_min_nelem'
    case ('fields.solver.near_field_precision')
      reader_path = 'sim.near_field_precision'
    case ('fields.periodic.image_layers')
      reader_path = 'sim.field_periodic_image_layers'
    case ('fields.periodic.backend')
      reader_path = 'sim.field_periodic_far_correction'
    case ('fields.periodic.ewald_alpha')
      reader_path = 'sim.field_periodic_ewald_alpha'
    case ('fields.periodic.ewald_layers')
      reader_path = 'sim.field_periodic_ewald_layers'
    case ('fields.periodic.cache_dir')
      reader_path = 'sim.field_periodic_cache_dir'
    case ('fields.periodic.generation_tolerance')
      reader_path = 'sim.field_periodic_generation_tolerance'
    case ('fields.external.electric_v_m')
      reader_path = 'sim.e0'
    case ('fields.external.electric_magnitude_v_m')
      reader_path = 'sim.e0_abs'
    case ('fields.external.electric_azimuth_deg')
      reader_path = 'sim.e0_phi_xy_deg'
    case ('fields.external.electric_elevation_deg')
      reader_path = 'sim.e0_phi_z_deg'
    case ('fields.external.magnetic_t')
      reader_path = 'sim.b0'
    case ('particles.tracking.events.policy')
      reader_path = 'sim.multiple_box_events_policy'
    case ('particles.tracking.events.retry_backend')
      reader_path = 'sim.multiple_box_events_retry_backend'
    case ('particles.tracking.events.discard_count_grace')
      reader_path = 'sim.multiple_box_events_soft_discard_count_grace'
    case ('particles.tracking.events.discard_fraction_limit')
      reader_path = 'sim.multiple_box_events_soft_discard_fraction_limit'
    case ('particles.tracking.events.discard_charge_warning_c')
      reader_path = 'sim.multiple_box_events_soft_discard_abs_charge_limit'
    case ('particles.raycast.max_bounces')
      reader_path = 'sim.raycast_max_bounce'
    case ('particles.secondary_emission.max_generations')
      reader_path = 'particles.secondary_emission_max_generations'
    case ('fields.periodic.upper_fourier.switch_height')
      reader_path = 'periodic2.upper_fourier_switch_height'
    case ('fields.periodic.upper_fourier.mode_layers')
      reader_path = 'periodic2.upper_fourier_mode_layers'
    case ('fields.periodic.lower_boundary_model')
      reader_path = 'periodic2.lower_boundary_model'
    case ('fields.periodic.reference.mode_layers')
      reader_path = 'periodic2.reference_mode_layers'
    case ('fields.periodic.reference.panel_quadrature_order')
      reader_path = 'periodic2.panel_quadrature_order'
    case ('run.batch.adaptive.max_nonzero_mode_potential_step_v')
      reader_path = 'periodic2.max_nonzero_mode_potential_step'
    case ('sheath.closure')
      reader_path = 'surface_current_model.model'
    case ('sheath.zhao.branch')
      reader_path = 'surface_current_model.zhao_branch'
    case ('sheath.species.electron')
      reader_path = 'surface_current_model.electron_species'
    case ('sheath.species.ion')
      reader_path = 'surface_current_model.ion_species'
    case ('sheath.species.photoelectron')
      reader_path = 'surface_current_model.photoelectron_species'
    case ('sheath.species.secondary_electron')
      reader_path = 'surface_current_model.secondary_electron_species'
    case ('sheath.photoelectrons.solar_elevation_deg')
      reader_path = 'surface_current_model.solar_elevation_deg'
    case ('sheath.photoelectrons.ref_density_m3')
      reader_path = 'surface_current_model.photoelectron_ref_density_m3'
    case ('sheath.photoelectrons.source_scale')
      reader_path = 'surface_current_model.photoelectron_source_scale'
    case ('sheath.reference_area_m2')
      reader_path = 'surface_current_model.reference_area_m2'
    case ('sheath.coupling.outflow_refresh_batches')
      reader_path = 'surface_current_model.outflow_refresh_batches'
    case ('sheath.coupling.include_reflected_electrons')
      reader_path = 'surface_current_model.include_reflected_electrons'
    case ('sheath.zhao.upstream_band_tolerance')
      reader_path = 'surface_current_model.zhao_upstream_band_tolerance'
    case ('sheath.zhao.upstream_field_floor_v_m')
      reader_path = 'surface_current_model.zhao_upstream_field_floor_v_m'
    case ('sheath.zhao.ion_pressure_factor')
      reader_path = 'surface_current_model.zhao_ion_pressure_factor'
    case ('output.enabled')
      reader_path = 'output.write_files'
    case ('output.dir')
      reader_path = 'output.dir'
    case ('output.final.mesh_potential')
      reader_path = 'output.write_mesh_potential'
    case ('output.history.potential')
      reader_path = 'output.write_potential_history'
    case ('output.history.stride_batches')
      reader_path = 'output.history_stride'
    case ('output.checkpoint.stride_batches')
      reader_path = 'output.checkpoint_stride'
    case ('run.restart.from')
      reader_path = 'output.restart_from'
    case ('fields.boundary')
      reader_path = 'field_boundary.mode'
    case ('particles.boundary.x_low')
      reader_path = 'particle_boundary.x_low'
    case ('particles.boundary.x_high')
      reader_path = 'particle_boundary.x_high'
    case ('particles.boundary.y_low')
      reader_path = 'particle_boundary.y_low'
    case ('particles.boundary.y_high')
      reader_path = 'particle_boundary.y_high'
    case ('particles.boundary.z_low')
      reader_path = 'particle_boundary.z_low'
    case ('particles.boundary.z_high')
      reader_path = 'particle_boundary.z_high'
    case ('particles.reservoir.inflow_model')
      reader_path = 'reservoir.inflow_model'
    case ('particles.reservoir.phi_infty_v')
      reader_path = 'reservoir.phi_infty'
    case ('particles.reservoir.face_potential_grid_n')
      reader_path = 'reservoir.face_potential_grid_n'
    case ('domain')
      reader_path = 'domain'
    case ('mesh.groups')
      reader_path = 'mesh.groups'
    case ('mesh.parts')
      reader_path = 'mesh.parts'
    case ('particles.species.species_key')
      reader_path = 'particles.species.species_key'
    case ('particles.species.enabled')
      reader_path = 'particles.species.enabled'
    case ('particles.species.charge_c')
      reader_path = 'particles.species.q_particle'
    case ('particles.species.mass_kg')
      reader_path = 'particles.species.m_particle'
    case ('particles.species.distribution.number_density_cm3')
      reader_path = 'particles.species.number_density_cm3'
    case ('particles.species.distribution.number_density_m3')
      reader_path = 'particles.species.number_density_m3'
    case ('particles.species.distribution.temperature_ev')
      reader_path = 'particles.species.temperature_ev'
    case ('particles.species.distribution.temperature_k')
      reader_path = 'particles.species.temperature_k'
    case ('particles.species.distribution.drift_velocity_m_s')
      reader_path = 'particles.species.drift_velocity'
    case ('particles.species.source.mode')
      reader_path = 'particles.species.source_mode'
    case ('particles.species.source.pos_low')
      reader_path = 'particles.species.pos_low'
    case ('particles.species.source.pos_high')
      reader_path = 'particles.species.pos_high'
    case ('particles.species.source.inject_face')
      reader_path = 'particles.species.inject_face'
    case ('particles.species.source.ray_direction')
      reader_path = 'particles.species.ray_direction'
    case ('particles.species.source.region_mode')
      reader_path = 'particles.species.inject_region_mode'
    case ('particles.species.source.uv_low')
      reader_path = 'particles.species.uv_low'
    case ('particles.species.source.uv_high')
      reader_path = 'particles.species.uv_high'
    case ('particles.species.source.emit_current_density_a_m2')
      reader_path = 'particles.species.emit_current_density_a_m2'
    case ('particles.species.source.deposit_opposite_charge_on_emit')
      reader_path = 'particles.species.deposit_opposite_charge_on_emit'
    case ('particles.species.source.normal_drift_speed_m_s')
      reader_path = 'particles.species.normal_drift_speed'
    case ('particles.species.sampling.volume_macro_particles_per_batch')
      reader_path = 'particles.species.npcls_per_step'
    case ('particles.species.sampling.weight')
      reader_path = 'particles.species.w_particle'
    case ('particles.species.sampling.target_macro_particles_per_batch')
      reader_path = 'particles.species.target_macro_particles_per_batch'
    case ('particles.species.sampling.rays_per_batch')
      reader_path = 'particles.species.rays_per_batch'
    case ('particles.species.charging.closure')
      reader_path = 'particles.species.surface_charge_closure'
    case ('particles.species.charging.target_absorbed_current_a')
      reader_path = 'particles.species.target_absorbed_current_a'
    case ('particles.species.charging.target_emission_current_a')
      reader_path = 'particles.species.target_emission_current_a'
    case ('particles.species.boundary')
      reader_path = 'particles.species.boundary'
    case ('particles.species.inflow')
      reader_path = 'particles.species.boundary_inflow'
    case ('particles.species.surface_interaction.secondary_emission.enabled')
      reader_path = 'particles.species.secondary_emission_enabled'
    case ('particles.species.surface_interaction.secondary_emission.model')
      reader_path = 'particles.species.secondary_emission_model'
    case ('particles.species.surface_interaction.secondary_emission.yield_max')
      reader_path = 'particles.species.secondary_emission_yield_max'
    case ('particles.species.surface_interaction.secondary_emission.energy_max_ev')
      reader_path = 'particles.species.secondary_emission_energy_max_ev'
    case ('particles.species.surface_interaction.secondary_emission.const_yield')
      reader_path = 'particles.species.secondary_emission_const_yield'
    case ('particles.species.surface_interaction.secondary_emission.target_species')
      reader_path = 'particles.species.secondary_emission_target_species'
    case default
      reader_path = ''
    end select
  end function reader_layout_path

  !> Recognize structural tables, rejecting unknown empty groups.
  logical function grouped_layout_table(path) result(known)
    character(len=*), intent(in) :: path
    select case (path)
    case ('')
      known = .true.
    case ('fields')
      known = .true.
    case ('fields.external')
      known = .true.
    case ('fields.periodic')
      known = .true.
    case ('fields.periodic.reference')
      known = .true.
    case ('fields.periodic.upper_fourier')
      known = .true.
    case ('fields.solver')
      known = .true.
    case ('fields.solver.tree')
      known = .true.
    case ('mesh')
      known = .true.
    case ('output')
      known = .true.
    case ('output.checkpoint')
      known = .true.
    case ('output.diagnostics')
      known = .true.
    case ('output.final')
      known = .true.
    case ('output.history')
      known = .true.
    case ('particles')
      known = .true.
    case ('particles.boundary')
      known = .true.
    case ('particles.raycast')
      known = .true.
    case ('particles.reservoir')
      known = .true.
    case ('particles.secondary_emission')
      known = .true.
    case ('particles.species')
      known = .true.
    case ('particles.species.charging')
      known = .true.
    case ('particles.species.distribution')
      known = .true.
    case ('particles.species.sampling')
      known = .true.
    case ('particles.species.source')
      known = .true.
    case ('particles.species.surface_interaction')
      known = .true.
    case ('particles.species.surface_interaction.secondary_emission')
      known = .true.
    case ('particles.tracking')
      known = .true.
    case ('particles.tracking.events')
      known = .true.
    case ('run')
      known = .true.
    case ('run.batch')
      known = .true.
    case ('run.batch.adaptive')
      known = .true.
    case ('run.restart')
      known = .true.
    case ('sheath')
      known = .true.
    case ('sheath.coupling')
      known = .true.
    case ('sheath.photoelectrons')
      known = .true.
    case ('sheath.species')
      known = .true.
    case ('sheath.zhao')
      known = .true.
    case default
      known = .false.
    end select
  end function grouped_layout_table
end module bem_config_layout_paths
