load_toml_config Subroutine

public subroutine load_toml_config(path, cfg)

TOML 文書を toml-f で解釈して設定へ反映する。 現在は sim / mesh / output / [[mesh.templates]] / [[particles.species]] を扱う。

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path

読み込むTOMLファイルパス。

type(app_config), intent(inout) :: cfg

読み込み結果で更新するアプリ設定。


Calls

proc~~load_toml_config~~CallsGraph proc~load_toml_config load_toml_config destroy destroy proc~load_toml_config->destroy proc~apply_toml_document apply_toml_document proc~load_toml_config->proc~apply_toml_document proc~init_app_config_authoring init_app_config_authoring proc~load_toml_config->proc~init_app_config_authoring proc~resolve_surface_current_model_path resolve_surface_current_model_path proc~load_toml_config->proc~resolve_surface_current_model_path toml_parse toml_parse proc~load_toml_config->toml_parse get_keys get_keys proc~apply_toml_document->get_keys get_value get_value proc~apply_toml_document->get_value interface~apply_domain_toml_table apply_domain_toml_table proc~apply_toml_document->interface~apply_domain_toml_table interface~apply_field_boundary_toml_table apply_field_boundary_toml_table proc~apply_toml_document->interface~apply_field_boundary_toml_table interface~apply_mesh_toml_table apply_mesh_toml_table proc~apply_toml_document->interface~apply_mesh_toml_table interface~apply_output_toml_table apply_output_toml_table proc~apply_toml_document->interface~apply_output_toml_table interface~apply_particle_boundary_toml_table apply_particle_boundary_toml_table proc~apply_toml_document->interface~apply_particle_boundary_toml_table interface~apply_particles_toml_table apply_particles_toml_table proc~apply_toml_document->interface~apply_particles_toml_table interface~apply_periodic2_toml_table apply_periodic2_toml_table proc~apply_toml_document->interface~apply_periodic2_toml_table interface~apply_reservoir_toml_table apply_reservoir_toml_table proc~apply_toml_document->interface~apply_reservoir_toml_table interface~apply_sim_toml_table apply_sim_toml_table proc~apply_toml_document->interface~apply_sim_toml_table interface~apply_surface_current_model_toml_table apply_surface_current_model_toml_table proc~apply_toml_document->interface~apply_surface_current_model_toml_table proc~lower_ascii lower_ascii proc~apply_toml_document->proc~lower_ascii proc~require_toml_success require_toml_success proc~apply_toml_document->proc~require_toml_success proc~stop_config_error stop_config_error proc~require_toml_success->proc~stop_config_error

Called by

proc~~load_toml_config~~CalledByGraph proc~load_toml_config load_toml_config proc~load_app_config load_app_config proc~load_app_config->proc~load_toml_config proc~handle_early_cli handle_early_cli proc~handle_early_cli->proc~load_app_config proc~load_or_init_run_state load_or_init_run_state proc~load_or_init_run_state->proc~load_app_config program~zhao_atlas_main zhao_atlas_main program~zhao_atlas_main->proc~load_app_config program~zhao_response_main zhao_response_main program~zhao_response_main->proc~load_app_config program~main main program~main->proc~handle_early_cli program~main->proc~load_or_init_run_state

Source Code

  subroutine load_toml_config(path, cfg)
    character(len=*), intent(in) :: path
    type(app_config), intent(inout) :: cfg
    integer :: u, ios
    type(config_toml_table), allocatable :: document
    type(toml_error), allocatable :: parse_error
    type(app_config_authoring) :: authoring

    if (.not. allocated(cfg%templates)) then
      allocate (cfg%templates(max_templates))
      cfg%n_templates = 0_i32
    end if
    if (.not. allocated(cfg%particle_species)) then
      allocate (cfg%particle_species(max_particle_species))
      cfg%particle_species = particle_species_spec()
      cfg%n_particle_species = 0_i32
    end if
    call init_app_config_authoring(authoring, size(cfg%templates), size(cfg%particle_species))

    open (newunit=u, file=trim(path), status='old', action='read', iostat=ios)
    if (ios /= 0) error stop 'Could not open TOML file.'
    call toml_parse(document, u, parse_error)
    close (u)
    if (allocated(parse_error)) then
      error stop 'Failed to parse TOML config: '//parse_error%message
    end if
    if (.not. allocated(document)) error stop 'Failed to parse TOML config.'

    call apply_toml_document(cfg, document, authoring)
    call document%destroy
    call resolve_surface_current_model_path(path, cfg)
    call finalize_loaded_config(cfg, authoring)
  end subroutine load_toml_config