load_or_init_run_state Subroutine

subroutine load_or_init_run_state(app, mesh, initial_stats, inject_state, 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

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

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_periodic2_collision_mesh prepare_periodic2_collision_mesh proc~load_or_init_run_state->proc~prepare_periodic2_collision_mesh proc~resolve_config_path resolve_config_path proc~load_or_init_run_state->proc~resolve_config_path proc~seed_particles_from_config seed_particles_from_config proc~load_or_init_run_state->proc~seed_particles_from_config proc~apply_obj_transform apply_obj_transform proc~build_mesh_from_config->proc~apply_obj_transform proc~apply_uniform_epsilon_r apply_uniform_epsilon_r proc~build_mesh_from_config->proc~apply_uniform_epsilon_r proc~apply_uniform_surface_model apply_uniform_surface_model proc~build_mesh_from_config->proc~apply_uniform_surface_model proc~build_template_mesh build_template_mesh proc~build_mesh_from_config->proc~build_template_mesh proc~load_obj_mesh load_obj_mesh proc~build_mesh_from_config->proc~load_obj_mesh proc~lower_ascii lower_ascii proc~build_mesh_from_config->proc~lower_ascii proc~surface_model_id_from_name surface_model_id_from_name proc~build_mesh_from_config->proc~surface_model_id_from_name 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~load_app_config->proc~lower_ascii proc~mpi_get_rank_size mpi_get_rank_size proc~load_restart_checkpoint->proc~mpi_get_rank_size proc~restart_macro_residual_path restart_macro_residual_path proc~load_restart_checkpoint->proc~restart_macro_residual_path proc~restart_rng_state_path restart_rng_state_path proc~load_restart_checkpoint->proc~restart_rng_state_path proc~resolve_periodic2_collision_config~2 resolve_periodic2_collision_config proc~prepare_periodic2_collision_mesh->proc~resolve_periodic2_collision_config~2 proc~update_mesh_geometry update_mesh_geometry proc~prepare_periodic2_collision_mesh->proc~update_mesh_geometry 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 proc~init_mesh init_mesh proc~apply_obj_transform->proc~init_mesh proc~build_template_mesh->proc~surface_model_id_from_name proc~append_mesh_ids append_mesh_ids proc~build_template_mesh->proc~append_mesh_ids proc~append_real_values append_real_values proc~build_template_mesh->proc~append_real_values proc~append_triangles append_triangles proc~build_template_mesh->proc~append_triangles proc~build_one_template build_one_template proc~build_template_mesh->proc~build_one_template proc~build_template_mesh->proc~init_mesh 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~load_toml_config->proc~lower_ascii destroy destroy proc~load_toml_config->destroy interface~resolve_batch_duration resolve_batch_duration proc~load_toml_config->interface~resolve_batch_duration interface~resolve_external_e_field resolve_external_e_field proc~load_toml_config->interface~resolve_external_e_field interface~validate_photo_raycast_species validate_photo_raycast_species proc~load_toml_config->interface~validate_photo_raycast_species interface~validate_reservoir_species validate_reservoir_species proc~load_toml_config->interface~validate_reservoir_species proc~apply_toml_document apply_toml_document proc~load_toml_config->proc~apply_toml_document proc~config_uses_conductor_surface_model config_uses_conductor_surface_model proc~load_toml_config->proc~config_uses_conductor_surface_model proc~init_app_config_authoring init_app_config_authoring proc~load_toml_config->proc~init_app_config_authoring proc~normalize_high_level_config normalize_high_level_config proc~load_toml_config->proc~normalize_high_level_config toml_parse toml_parse proc~load_toml_config->toml_parse proc~resolve_parallel_rank_size->proc~mpi_get_rank_size proc~resolve_periodic2_collision_config~2->proc~lower_ascii proc~restart_macro_residual_path->proc~mpi_get_rank_size proc~restart_rng_state_path->proc~mpi_get_rank_size proc~surface_model_id_from_name->proc~lower_ascii proc~build_collision_grid build_collision_grid proc~update_mesh_geometry->proc~build_collision_grid proc~cross~3 cross proc~update_mesh_geometry->proc~cross~3 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 proc~apply_mesh_toml_table apply_mesh_toml_table proc~apply_toml_document->proc~apply_mesh_toml_table proc~apply_output_toml_table apply_output_toml_table proc~apply_toml_document->proc~apply_output_toml_table proc~apply_particles_toml_table apply_particles_toml_table proc~apply_toml_document->proc~apply_particles_toml_table proc~apply_sim_toml_table apply_sim_toml_table proc~apply_toml_document->proc~apply_sim_toml_table proc~require_toml_success require_toml_success proc~apply_toml_document->proc~require_toml_success proc~cell_id~2 cell_id proc~build_collision_grid->proc~cell_id~2 proc~coord_to_cell~2 coord_to_cell proc~build_collision_grid->proc~coord_to_cell~2 proc~build_mesh_from_indexed->proc~init_mesh 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_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~init_mesh->proc~update_mesh_geometry proc~normalize_high_level_config->proc~lower_ascii 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~strip_cr strip_cr proc~parse_obj->proc~strip_cr 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~strip_cr proc~apply_mesh_toml_table->proc~lower_ascii proc~apply_mesh_toml_table->get_keys proc~get_toml_real get_toml_real proc~apply_mesh_toml_table->proc~get_toml_real proc~get_toml_real3 get_toml_real3 proc~apply_mesh_toml_table->proc~get_toml_real3 proc~get_toml_string get_toml_string proc~apply_mesh_toml_table->proc~get_toml_string proc~read_mesh_groups_table read_mesh_groups_table proc~apply_mesh_toml_table->proc~read_mesh_groups_table proc~read_template_array read_template_array proc~apply_mesh_toml_table->proc~read_template_array proc~apply_output_toml_table->proc~lower_ascii proc~apply_output_toml_table->get_keys proc~get_toml_int get_toml_int proc~apply_output_toml_table->proc~get_toml_int proc~get_toml_logical get_toml_logical proc~apply_output_toml_table->proc~get_toml_logical proc~apply_output_toml_table->proc~get_toml_string proc~apply_particles_toml_table->proc~lower_ascii proc~apply_particles_toml_table->get_keys proc~read_particle_species_array read_particle_species_array proc~apply_particles_toml_table->proc~read_particle_species_array proc~apply_sim_toml_table->proc~lower_ascii proc~apply_sim_toml_table->get_keys proc~get_toml_boundary_mode get_toml_boundary_mode proc~apply_sim_toml_table->proc~get_toml_boundary_mode proc~apply_sim_toml_table->proc~get_toml_int proc~apply_sim_toml_table->proc~get_toml_logical proc~apply_sim_toml_table->proc~get_toml_real proc~apply_sim_toml_table->proc~get_toml_real3 proc~apply_sim_toml_table->proc~get_toml_string 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_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~sph sph proc~make_sphere->proc~sph proc~get_toml_boundary_mode->proc~lower_ascii proc~get_toml_boundary_mode->proc~get_toml_string proc~get_toml_int->get_value proc~get_toml_int->proc~require_toml_success proc~get_toml_logical->get_value proc~get_toml_logical->proc~require_toml_success proc~get_toml_real->get_value proc~get_toml_real->proc~require_toml_success proc~get_toml_real3->get_value proc~get_toml_real3->proc~require_toml_success toml_len toml_len proc~get_toml_real3->toml_len proc~get_toml_string->get_value proc~get_toml_string->proc~require_toml_success proc~read_mesh_groups_table->get_keys proc~read_mesh_groups_table->get_value proc~read_mesh_groups_table->proc~require_toml_success proc~apply_mesh_group_toml_table apply_mesh_group_toml_table proc~read_mesh_groups_table->proc~apply_mesh_group_toml_table proc~ensure_authoring_group_capacity ensure_authoring_group_capacity proc~read_mesh_groups_table->proc~ensure_authoring_group_capacity proc~read_particle_species_array->get_value proc~read_particle_species_array->proc~require_toml_success proc~apply_particles_species_toml_table apply_particles_species_toml_table proc~read_particle_species_array->proc~apply_particles_species_toml_table proc~ensure_authoring_particle_capacity ensure_authoring_particle_capacity proc~read_particle_species_array->proc~ensure_authoring_particle_capacity proc~ensure_particle_species_capacity ensure_particle_species_capacity proc~read_particle_species_array->proc~ensure_particle_species_capacity proc~species_from_defaults species_from_defaults proc~read_particle_species_array->proc~species_from_defaults proc~read_particle_species_array->toml_len proc~read_template_array->get_value proc~read_template_array->proc~require_toml_success proc~apply_template_toml_table apply_template_toml_table proc~read_template_array->proc~apply_template_toml_table proc~ensure_authoring_template_capacity ensure_authoring_template_capacity proc~read_template_array->proc~ensure_authoring_template_capacity proc~ensure_template_capacity ensure_template_capacity proc~read_template_array->proc~ensure_template_capacity proc~read_template_array->toml_len 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 proc~apply_mesh_group_toml_table->proc~lower_ascii proc~apply_mesh_group_toml_table->get_keys proc~apply_mesh_group_toml_table->proc~get_toml_real proc~apply_mesh_group_toml_table->proc~get_toml_real3 proc~apply_mesh_group_toml_table->proc~get_toml_string proc~apply_particles_species_toml_table->proc~lower_ascii proc~apply_particles_species_toml_table->get_keys proc~apply_particles_species_toml_table->proc~get_toml_int proc~apply_particles_species_toml_table->proc~get_toml_logical proc~apply_particles_species_toml_table->proc~get_toml_real proc~apply_particles_species_toml_table->proc~get_toml_real3 proc~apply_particles_species_toml_table->proc~get_toml_string proc~get_toml_real2 get_toml_real2 proc~apply_particles_species_toml_table->proc~get_toml_real2 proc~apply_template_toml_table->proc~lower_ascii proc~apply_template_toml_table->get_keys proc~apply_template_toml_table->proc~get_toml_int proc~apply_template_toml_table->proc~get_toml_logical proc~apply_template_toml_table->proc~get_toml_real proc~apply_template_toml_table->proc~get_toml_real3 proc~apply_template_toml_table->proc~get_toml_string proc~get_toml_real_scalar_or_array3 get_toml_real_scalar_or_array3 proc~apply_template_toml_table->proc~get_toml_real_scalar_or_array3 proc~get_toml_real2->get_value proc~get_toml_real2->proc~require_toml_success proc~get_toml_real2->toml_len proc~get_toml_real_scalar_or_array3->get_value proc~get_toml_real_scalar_or_array3->proc~require_toml_success proc~get_toml_real_scalar_or_array3->toml_len

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, 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
    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

    call build_mesh_from_config(app, mesh)
    call prepare_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
      if (.not. app%write_output) error stop 'output.resume requires output.write_files = true.'
      restart_dir = app%output_dir
      if (len_trim(app%output_restart_from) > 0) restart_dir = app%output_restart_from
      call load_restart_checkpoint( &
        trim(restart_dir), mesh, initial_stats, resumed, inject_state, &
        mpi=mpi, require_checkpoint=.true. &
        )
    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