load_or_init_run_state Subroutine

subroutine load_or_init_run_state(app, mesh, initial_stats, inject_state, charge_ledger, resumed, mpi)

設定読込・メッシュ構築・再開判定・乱数初期化をまとめて行う。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(out) :: app

読み込み・既定値適用後のアプリ設定。

type(mesh_type), intent(out) :: mesh

構築した三角形メッシュ。

type(sim_stats), intent(out) :: initial_stats

再開時に引き継ぐ初期統計(新規実行時はゼロ)。

type(injection_state), intent(out) :: inject_state

種別ごとの注入残差状態。

type(charge_ledger_type), intent(out) :: charge_ledger
logical, intent(out) :: resumed

チェックポイントから再開した場合に .true.。

type(mpi_context), intent(in) :: mpi

Calls

proc~~load_or_init_run_state~~CallsGraph proc~load_or_init_run_state load_or_init_run_state proc~build_mesh_from_config build_mesh_from_config proc~load_or_init_run_state->proc~build_mesh_from_config proc~default_app_config default_app_config proc~load_or_init_run_state->proc~default_app_config proc~initialize_injection_state initialize_injection_state proc~load_or_init_run_state->proc~initialize_injection_state proc~load_app_config load_app_config proc~load_or_init_run_state->proc~load_app_config proc~load_restart_checkpoint load_restart_checkpoint proc~load_or_init_run_state->proc~load_restart_checkpoint proc~mpi_is_root mpi_is_root proc~load_or_init_run_state->proc~mpi_is_root proc~prepare_built_periodic2_collision_mesh prepare_built_periodic2_collision_mesh proc~load_or_init_run_state->proc~prepare_built_periodic2_collision_mesh proc~resolve_config_path resolve_config_path proc~load_or_init_run_state->proc~resolve_config_path proc~resolve_latest_checkpoint_dir resolve_latest_checkpoint_dir proc~load_or_init_run_state->proc~resolve_latest_checkpoint_dir proc~seed_particles_from_config seed_particles_from_config proc~load_or_init_run_state->proc~seed_particles_from_config proc~apply_panel_surface_config apply_panel_surface_config proc~build_mesh_from_config->proc~apply_panel_surface_config proc~build_parts_mesh build_parts_mesh proc~build_mesh_from_config->proc~build_parts_mesh proc~default_periodic_cache_directory default_periodic_cache_directory proc~default_app_config->proc~default_periodic_cache_directory proc~normalize_legacy_physics_config normalize_legacy_physics_config proc~default_app_config->proc~normalize_legacy_physics_config proc~has_suffix has_suffix proc~load_app_config->proc~has_suffix proc~load_toml_config load_toml_config proc~load_app_config->proc~load_toml_config proc~lower_ascii lower_ascii proc~load_app_config->proc~lower_ascii interface~restart_macro_residual_path restart_macro_residual_path proc~load_restart_checkpoint->interface~restart_macro_residual_path interface~restart_rng_state_path restart_rng_state_path proc~load_restart_checkpoint->interface~restart_rng_state_path interface~validate_restart_contract validate_restart_contract proc~load_restart_checkpoint->interface~validate_restart_contract none~init charge_ledger_type%init proc~load_restart_checkpoint->none~init proc~checkpoint_schema_is_loadable checkpoint_schema_is_loadable proc~load_restart_checkpoint->proc~checkpoint_schema_is_loadable proc~inspect_checkpoint_directory inspect_checkpoint_directory proc~load_restart_checkpoint->proc~inspect_checkpoint_directory proc~mpi_bcast_real_dp_array mpi_bcast_real_dp_array proc~load_restart_checkpoint->proc~mpi_bcast_real_dp_array proc~resolve_periodic2_axes resolve_periodic2_axes proc~prepare_built_periodic2_collision_mesh->proc~resolve_periodic2_axes proc~update_mesh_geometry update_mesh_geometry proc~prepare_built_periodic2_collision_mesh->proc~update_mesh_geometry proc~resolve_latest_checkpoint_dir->proc~inspect_checkpoint_directory proc~resolve_parallel_rank_size resolve_parallel_rank_size proc~seed_particles_from_config->proc~resolve_parallel_rank_size proc~seed_rng seed_rng proc~seed_particles_from_config->proc~seed_rng none~reset charge_ledger_type%reset none~init->none~reset proc~mesh_part_config_path mesh_part_config_path proc~apply_panel_surface_config->proc~mesh_part_config_path proc~resolve_panel_surface_sides_by_mesh_id resolve_panel_surface_sides_by_mesh_id proc~apply_panel_surface_config->proc~resolve_panel_surface_sides_by_mesh_id proc~apply_obj_transform apply_obj_transform proc~build_parts_mesh->proc~apply_obj_transform proc~build_one_template build_one_template proc~build_parts_mesh->proc~build_one_template proc~init_mesh init_mesh proc~build_parts_mesh->proc~init_mesh proc~load_obj_mesh load_obj_mesh proc~build_parts_mesh->proc~load_obj_mesh proc~surface_model_id_from_name surface_model_id_from_name proc~build_parts_mesh->proc~surface_model_id_from_name proc~inspect_checkpoint_directory->proc~checkpoint_schema_is_loadable 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~normalize_config_layout normalize_config_layout proc~load_toml_config->proc~normalize_config_layout toml_parse toml_parse proc~load_toml_config->toml_parse proc~normalize_legacy_physics_config->proc~lower_ascii proc~derive_field_panel_config derive_field_panel_config proc~normalize_legacy_physics_config->proc~derive_field_panel_config proc~mpi_get_rank_size mpi_get_rank_size proc~resolve_parallel_rank_size->proc~mpi_get_rank_size proc~resolve_periodic2_axes->proc~lower_ascii proc~seed_random_stream seed_random_stream proc~seed_rng->proc~seed_random_stream proc~build_collision_grid build_collision_grid proc~update_mesh_geometry->proc~build_collision_grid proc~cross~2 cross proc~update_mesh_geometry->proc~cross~2 proc~fill_panel_quadrature fill_panel_quadrature proc~update_mesh_geometry->proc~fill_panel_quadrature proc~init_panel_geometry init_panel_geometry proc~update_mesh_geometry->proc~init_panel_geometry proc~apply_obj_transform->proc~init_mesh proc~apply_toml_document->proc~lower_ascii 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~require_toml_success require_toml_success proc~apply_toml_document->proc~require_toml_success proc~cell_id cell_id proc~build_collision_grid->proc~cell_id proc~coord_to_cell coord_to_cell proc~build_collision_grid->proc~coord_to_cell proc~build_one_template->proc~lower_ascii proc~make_annulus make_annulus proc~build_one_template->proc~make_annulus proc~make_box make_box proc~build_one_template->proc~make_box proc~make_cylinder make_cylinder proc~build_one_template->proc~make_cylinder proc~make_disk make_disk proc~build_one_template->proc~make_disk proc~make_icosphere make_icosphere proc~build_one_template->proc~make_icosphere proc~make_plane make_plane proc~build_one_template->proc~make_plane proc~make_plate_hole make_plate_hole proc~build_one_template->proc~make_plate_hole proc~make_sphere make_sphere proc~build_one_template->proc~make_sphere proc~derive_field_panel_config->proc~lower_ascii proc~init_mesh->proc~update_mesh_geometry proc~build_mesh_from_indexed build_mesh_from_indexed proc~load_obj_mesh->proc~build_mesh_from_indexed proc~parse_obj parse_obj proc~load_obj_mesh->proc~parse_obj proc~scan_obj scan_obj proc~load_obj_mesh->proc~scan_obj proc~normalize_config_layout->proc~lower_ascii proc~normalize_config_layout->destroy add_table add_table proc~normalize_config_layout->add_table get get proc~normalize_config_layout->get proc~normalize_config_layout->get_keys proc~normalize_config_layout->get_value new_array new_array proc~normalize_config_layout->new_array new_table new_table proc~normalize_config_layout->new_table proc~get_toml_int get_toml_int proc~normalize_config_layout->proc~get_toml_int proc~grouped_layout_table grouped_layout_table proc~normalize_config_layout->proc~grouped_layout_table proc~reader_layout_path reader_layout_path proc~normalize_config_layout->proc~reader_layout_path proc~normalize_config_layout->proc~require_toml_success proc~stop_config_error stop_config_error proc~normalize_config_layout->proc~stop_config_error push_back push_back proc~normalize_config_layout->push_back set_value set_value proc~normalize_config_layout->set_value toml_len toml_len proc~normalize_config_layout->toml_len proc~resolve_panel_surface_sides_by_mesh_id->proc~lower_ascii proc~counter_key counter_key proc~seed_random_stream->proc~counter_key proc~surface_model_id_from_name->proc~lower_ascii proc~build_mesh_from_indexed->proc~init_mesh proc~get_toml_int->get_value proc~get_toml_int->proc~require_toml_success proc~get_toml_int->proc~stop_config_error proc~make_annulus->proc~init_mesh proc~push_tri push_tri proc~make_annulus->proc~push_tri proc~make_box->proc~init_mesh proc~make_box->proc~push_tri proc~make_cylinder->proc~init_mesh proc~make_cylinder->proc~push_tri proc~make_disk->proc~make_annulus proc~make_icosphere->proc~init_mesh proc~make_plane->proc~init_mesh proc~make_plate_hole->proc~init_mesh proc~make_plate_hole->proc~push_tri proc~ray_to_rectangle ray_to_rectangle proc~make_plate_hole->proc~ray_to_rectangle proc~transition_corner_count transition_corner_count proc~make_plate_hole->proc~transition_corner_count proc~transition_corners transition_corners proc~make_plate_hole->proc~transition_corners proc~make_sphere->proc~init_mesh proc~make_sphere->proc~push_tri proc~is_face_line is_face_line proc~parse_obj->proc~is_face_line proc~is_vertex_line is_vertex_line proc~parse_obj->proc~is_vertex_line proc~parse_face_line parse_face_line proc~parse_obj->proc~parse_face_line proc~parse_vertex_line parse_vertex_line proc~parse_obj->proc~parse_vertex_line proc~read_obj_line read_obj_line proc~parse_obj->proc~read_obj_line proc~require_toml_success->proc~stop_config_error proc~count_face_tokens count_face_tokens proc~scan_obj->proc~count_face_tokens proc~scan_obj->proc~is_face_line proc~scan_obj->proc~is_vertex_line proc~scan_obj->proc~read_obj_line proc~next_face_token next_face_token proc~count_face_tokens->proc~next_face_token proc~parse_face_line->proc~count_face_tokens proc~parse_face_line->proc~next_face_token proc~strip_cr strip_cr proc~read_obj_line->proc~strip_cr proc~edge_order_index edge_order_index proc~transition_corner_count->proc~edge_order_index proc~transition_corners->proc~transition_corner_count proc~corner_between corner_between proc~transition_corners->proc~corner_between proc~edge_next_ccw edge_next_ccw proc~transition_corners->proc~edge_next_ccw

Called by

proc~~load_or_init_run_state~~CalledByGraph proc~load_or_init_run_state load_or_init_run_state program~main main program~main->proc~load_or_init_run_state

Source Code

  subroutine load_or_init_run_state(app, mesh, initial_stats, inject_state, charge_ledger, resumed, mpi)
    type(app_config), intent(out) :: app
    type(mesh_type), intent(out) :: mesh
    type(sim_stats), intent(out) :: initial_stats
    type(injection_state), intent(out) :: inject_state
    type(charge_ledger_type), intent(out) :: charge_ledger
    logical, intent(out) :: resumed
    type(mpi_context), intent(in) :: mpi
    character(len=256) :: cfg_path
    character(len=256) :: restart_dir
    logical :: has_config

    call default_app_config(app)
    call resolve_config_path(cfg_path, has_config)
    if (has_config) then
      call load_app_config(trim(cfg_path), app)
    end if

    ! The cache-only mode never reads checkpoints; it only needs the mesh and field settings.
    if (prepare_cache_only) app%resume_output = .false.
    call build_mesh_from_config(app, mesh)
    call prepare_built_periodic2_collision_mesh(mesh, app%sim)
    call initialize_injection_state(inject_state, app%n_particle_species)
    initial_stats = sim_stats()
    resumed = .false.
    if (app%resume_output) then
      restart_dir = app%output_dir
      if (len_trim(app%output_restart_from) > 0) restart_dir = app%output_restart_from
      call resolve_latest_checkpoint_dir(trim(restart_dir), restart_dir)
      call load_restart_checkpoint( &
        trim(restart_dir), mesh, initial_stats, resumed, inject_state, &
        mpi=mpi, require_checkpoint=.true., app=app, charge_ledger=charge_ledger &
        )
    end if

    if (resumed) then
      if (mpi_is_root(mpi)) then
        print '(a,a)', 'resuming_from_dir=', trim(restart_dir)
        print '(a,i0)', 'resuming_from_batches=', initial_stats%batches
        print '(a,i0)', 'resuming_from_processed_particles=', initial_stats%processed_particles
      end if
    else
      call seed_particles_from_config(app, mpi=mpi)
    end if
  end subroutine load_or_init_run_state