main Program

Uses

  • program~~main~~UsesGraph program~main main iso_fortran_env iso_fortran_env program~main->iso_fortran_env module~bem_app_config bem_app_config program~main->module~bem_app_config module~bem_charge_ledger bem_charge_ledger program~main->module~bem_charge_ledger module~bem_checkpoint_contract bem_checkpoint_contract program~main->module~bem_checkpoint_contract module~bem_electrostatic_snapshot bem_electrostatic_snapshot program~main->module~bem_electrostatic_snapshot module~bem_kinds bem_kinds program~main->module~bem_kinds module~bem_matching_plane_response_provider bem_matching_plane_response_provider program~main->module~bem_matching_plane_response_provider module~bem_mesh bem_mesh program~main->module~bem_mesh module~bem_mpi bem_mpi program~main->module~bem_mpi module~bem_output_writer bem_output_writer program~main->module~bem_output_writer module~bem_performance_profile bem_performance_profile program~main->module~bem_performance_profile module~bem_periodic_checkpoint bem_periodic_checkpoint program~main->module~bem_periodic_checkpoint module~bem_restart bem_restart program~main->module~bem_restart module~bem_simulator bem_simulator program~main->module~bem_simulator module~bem_types bem_types program~main->module~bem_types module~bem_version bem_version program~main->module~bem_version module~bem_app_config_parser bem_app_config_parser module~bem_app_config->module~bem_app_config_parser module~bem_app_config_runtime bem_app_config_runtime module~bem_app_config->module~bem_app_config_runtime module~bem_app_config_types bem_app_config_types module~bem_app_config->module~bem_app_config_types module~bem_physics_config_types bem_physics_config_types module~bem_app_config->module~bem_physics_config_types module~bem_string_utils bem_string_utils module~bem_app_config->module~bem_string_utils module~bem_charge_ledger->module~bem_kinds ieee_arithmetic ieee_arithmetic module~bem_charge_ledger->ieee_arithmetic module~bem_checkpoint_contract->module~bem_kinds module~bem_filesystem bem_filesystem module~bem_checkpoint_contract->module~bem_filesystem module~bem_electrostatic_snapshot->module~bem_kinds module~bem_electrostatic_snapshot->module~bem_types module~bem_electrostatic_snapshot->ieee_arithmetic module~bem_constants bem_constants module~bem_electrostatic_snapshot->module~bem_constants module~bem_coulomb_fmm_periodic_nonzero_reference bem_coulomb_fmm_periodic_nonzero_reference module~bem_electrostatic_snapshot->module~bem_coulomb_fmm_periodic_nonzero_reference module~bem_coulomb_fmm_periodic_nonzero_upper_vacuum bem_coulomb_fmm_periodic_nonzero_upper_vacuum module~bem_electrostatic_snapshot->module~bem_coulomb_fmm_periodic_nonzero_upper_vacuum module~bem_field_solver bem_field_solver module~bem_electrostatic_snapshot->module~bem_field_solver module~bem_panel_geometry bem_panel_geometry module~bem_electrostatic_snapshot->module~bem_panel_geometry module~bem_panel_kernel bem_panel_kernel module~bem_electrostatic_snapshot->module~bem_panel_kernel module~bem_periodic_zero_mode_eval bem_periodic_zero_mode_eval module~bem_electrostatic_snapshot->module~bem_periodic_zero_mode_eval module~bem_periodic_zero_mode_plan bem_periodic_zero_mode_plan module~bem_electrostatic_snapshot->module~bem_periodic_zero_mode_plan module~bem_electrostatic_snapshot->module~bem_physics_config_types module~bem_electrostatic_snapshot->module~bem_string_utils module~bem_kinds->iso_fortran_env module~bem_matching_plane_response_provider->module~bem_kinds module~bem_matching_plane_response_provider->module~bem_mpi module~bem_matching_plane_response_provider->ieee_arithmetic module~bem_matching_plane_response_provider->module~bem_app_config_types module~bem_matching_plane_response bem_matching_plane_response module~bem_matching_plane_response_provider->module~bem_matching_plane_response module~bem_matching_plane_zhao bem_matching_plane_zhao module~bem_matching_plane_response_provider->module~bem_matching_plane_zhao module~bem_mesh->module~bem_kinds module~bem_mesh->module~bem_types module~bem_mesh->ieee_arithmetic module~bem_mesh->module~bem_panel_geometry module~bem_mesh->module~bem_string_utils module~bem_triangle_quadrature bem_triangle_quadrature module~bem_mesh->module~bem_triangle_quadrature module~bem_mpi->module~bem_kinds module~bem_output_writer->module~bem_charge_ledger module~bem_output_writer->module~bem_checkpoint_contract module~bem_output_writer->module~bem_electrostatic_snapshot module~bem_output_writer->module~bem_kinds module~bem_output_writer->module~bem_types module~bem_output_writer->module~bem_app_config_types module~bem_output_writer->module~bem_filesystem module~bem_performance_profile->iso_fortran_env module~bem_performance_profile->module~bem_kinds module~bem_performance_profile->module~bem_mpi module~bem_performance_profile->module~bem_string_utils module~bem_periodic_checkpoint->module~bem_charge_ledger module~bem_periodic_checkpoint->module~bem_checkpoint_contract module~bem_periodic_checkpoint->module~bem_kinds module~bem_periodic_checkpoint->module~bem_mpi module~bem_periodic_checkpoint->module~bem_output_writer module~bem_periodic_checkpoint->module~bem_restart module~bem_periodic_checkpoint->module~bem_types module~bem_periodic_checkpoint->module~bem_app_config_types module~bem_periodic_checkpoint->module~bem_filesystem module~bem_restart->module~bem_charge_ledger module~bem_restart->module~bem_checkpoint_contract module~bem_restart->module~bem_kinds module~bem_restart->module~bem_mpi module~bem_restart->module~bem_types module~bem_restart->ieee_arithmetic module~bem_restart->module~bem_app_config_types module~bem_simulator->iso_fortran_env module~bem_simulator->module~bem_app_config module~bem_simulator->module~bem_charge_ledger module~bem_simulator->module~bem_electrostatic_snapshot module~bem_simulator->module~bem_kinds module~bem_simulator->module~bem_mpi module~bem_simulator->module~bem_output_writer module~bem_simulator->module~bem_types module~bem_simulator->ieee_arithmetic module~bem_simulator->module~bem_app_config_runtime module~bem_collision bem_collision module~bem_simulator->module~bem_collision module~bem_config_helpers bem_config_helpers module~bem_simulator->module~bem_config_helpers module~bem_external_boundary_contract bem_external_boundary_contract module~bem_simulator->module~bem_external_boundary_contract module~bem_particle_stepper bem_particle_stepper module~bem_simulator->module~bem_particle_stepper module~bem_simulator->module~bem_physics_config_types module~bem_simulator_workspace bem_simulator_workspace module~bem_simulator->module~bem_simulator_workspace module~bem_simulator->module~bem_string_utils module~bem_surface_closure_contract bem_surface_closure_contract module~bem_simulator->module~bem_surface_closure_contract module~bem_surface_current_model bem_surface_current_model module~bem_simulator->module~bem_surface_current_model module~bem_surface_models bem_surface_models module~bem_simulator->module~bem_surface_models module~bem_types->module~bem_kinds module~bem_app_config_parser->module~bem_kinds module~bem_app_config_parser->module~bem_types module~bem_app_config_parser->ieee_arithmetic module~bem_app_config_parser->module~bem_app_config_types module~bem_app_config_parser->module~bem_physics_config_types module~bem_app_config_parser->module~bem_string_utils module~bem_app_config_authoring bem_app_config_authoring module~bem_app_config_parser->module~bem_app_config_authoring module~bem_config_toml bem_config_toml module~bem_app_config_parser->module~bem_config_toml module~bem_injection_flux bem_injection_flux module~bem_app_config_parser->module~bem_injection_flux module~bem_injection_geometry bem_injection_geometry module~bem_app_config_parser->module~bem_injection_geometry tomlf tomlf module~bem_app_config_parser->tomlf module~bem_app_config_mesh_runtime bem_app_config_mesh_runtime module~bem_app_config_runtime->module~bem_app_config_mesh_runtime module~bem_app_config_particle_runtime bem_app_config_particle_runtime module~bem_app_config_runtime->module~bem_app_config_particle_runtime module~bem_app_config_potential_runtime bem_app_config_potential_runtime module~bem_app_config_runtime->module~bem_app_config_potential_runtime module~bem_app_config_types->module~bem_kinds module~bem_app_config_types->module~bem_types module~bem_app_config_types->module~bem_physics_config_types module~bem_collision->iso_fortran_env module~bem_collision->module~bem_kinds module~bem_collision->module~bem_types module~bem_collision->ieee_arithmetic module~bem_collision->module~bem_string_utils module~bem_config_helpers->module~bem_kinds module~bem_config_helpers->module~bem_types module~bem_config_helpers->module~bem_app_config_types module~bem_config_helpers->module~bem_string_utils module~bem_constants->module~bem_kinds module~bem_coulomb_fmm_periodic_nonzero_reference->module~bem_kinds module~bem_coulomb_fmm_periodic_nonzero_reference->module~bem_types module~bem_coulomb_fmm_periodic_nonzero_reference->ieee_arithmetic module~bem_coulomb_fmm_periodic_nonzero_reference->module~bem_constants module~bem_coulomb_fmm_periodic_nonzero_reference->module~bem_panel_geometry module~bem_coulomb_fmm_periodic_nonzero_reference->module~bem_triangle_quadrature module~bem_coulomb_fmm_periodic_nonzero_upper_vacuum->module~bem_kinds module~bem_coulomb_fmm_periodic_nonzero_upper_vacuum->module~bem_types module~bem_coulomb_fmm_periodic_nonzero_upper_vacuum->ieee_arithmetic module~bem_coulomb_fmm_periodic_nonzero_upper_vacuum->module~bem_constants module~bem_external_boundary_contract->module~bem_kinds module~bem_external_boundary_contract->module~bem_string_utils module~bem_field_solver->module~bem_kinds module~bem_field_solver->module~bem_types module~bem_field_solver->ieee_arithmetic module~bem_field_solver->module~bem_constants module~bem_field_solver->module~bem_physics_config_types module~bem_field_solver->module~bem_string_utils module~bem_coulomb_fmm_core bem_coulomb_fmm_core module~bem_field_solver->module~bem_coulomb_fmm_core iso_c_binding iso_c_binding module~bem_filesystem->iso_c_binding module~bem_matching_plane_response->module~bem_kinds module~bem_matching_plane_response->module~bem_mpi module~bem_matching_plane_response->ieee_arithmetic module~bem_matching_plane_contract bem_matching_plane_contract module~bem_matching_plane_response->module~bem_matching_plane_contract module~bem_matching_plane_zhao->module~bem_kinds module~bem_matching_plane_zhao->ieee_arithmetic module~bem_matching_plane_zhao->module~bem_constants module~bem_matching_plane_zhao->module~bem_string_utils module~bem_matching_plane_zhao->module~bem_matching_plane_contract module~bem_sheath_model_core bem_sheath_model_core module~bem_matching_plane_zhao->module~bem_sheath_model_core module~bem_panel_geometry->module~bem_kinds module~bem_panel_geometry->ieee_arithmetic module~bem_panel_kernel->module~bem_kinds module~bem_panel_kernel->module~bem_constants module~bem_panel_kernel->module~bem_panel_geometry module~bem_panel_self_terms bem_panel_self_terms module~bem_panel_kernel->module~bem_panel_self_terms module~bem_particle_stepper->module~bem_electrostatic_snapshot module~bem_particle_stepper->module~bem_kinds module~bem_particle_stepper->module~bem_types module~bem_particle_stepper->ieee_arithmetic module~bem_particle_stepper->module~bem_collision module~bem_particle_stepper->module~bem_external_boundary_contract module~bem_boundary bem_boundary module~bem_particle_stepper->module~bem_boundary module~bem_pusher bem_pusher module~bem_particle_stepper->module~bem_pusher module~bem_periodic_zero_mode_eval->module~bem_kinds module~bem_periodic_zero_mode_eval->module~bem_constants module~bem_periodic_zero_mode_eval->module~bem_periodic_zero_mode_plan module~bem_periodic_zero_mode_plan->module~bem_kinds module~bem_periodic_zero_mode_plan->module~bem_types module~bem_periodic_zero_mode_plan->ieee_arithmetic module~bem_periodic_zero_mode_plan->module~bem_constants module~bem_physics_config_types->module~bem_kinds module~bem_physics_config_types->module~bem_types module~bem_physics_config_types->ieee_arithmetic module~bem_physics_config_types->module~bem_string_utils module~bem_simulator_workspace->module~bem_kinds module~bem_surface_closure_contract->module~bem_kinds module~bem_surface_current_model->module~bem_kinds module~bem_surface_current_model->ieee_arithmetic module~bem_surface_current_model->module~bem_app_config_types module~bem_surface_current_model->module~bem_config_helpers module~bem_surface_current_model->module~bem_constants module~bem_surface_current_model->module~bem_string_utils module~bem_surface_current_model->module~bem_surface_closure_contract module~bem_surface_current_model->module~bem_sheath_model_core module~bem_surface_models->module~bem_kinds module~bem_surface_models->module~bem_types module~bem_surface_models->module~bem_string_utils module~bem_triangle_quadrature->module~bem_kinds module~bem_triangle_quadrature->module~bem_constants module~bem_triangle_quadrature->module~bem_panel_geometry module~bem_app_config_authoring->module~bem_kinds module~bem_app_config_authoring->module~bem_app_config_types module~bem_app_config_authoring_types bem_app_config_authoring_types module~bem_app_config_authoring->module~bem_app_config_authoring_types module~bem_app_config_mesh_runtime->module~bem_kinds module~bem_app_config_mesh_runtime->module~bem_mesh module~bem_app_config_mesh_runtime->module~bem_types module~bem_app_config_mesh_runtime->ieee_arithmetic module~bem_app_config_mesh_runtime->module~bem_app_config_types module~bem_app_config_mesh_runtime->module~bem_string_utils module~bem_importers bem_importers module~bem_app_config_mesh_runtime->module~bem_importers module~bem_panel_surface_sides bem_panel_surface_sides module~bem_app_config_mesh_runtime->module~bem_panel_surface_sides module~bem_templates bem_templates module~bem_app_config_mesh_runtime->module~bem_templates module~bem_app_config_particle_runtime->iso_fortran_env module~bem_app_config_particle_runtime->module~bem_electrostatic_snapshot module~bem_app_config_particle_runtime->module~bem_kinds module~bem_app_config_particle_runtime->module~bem_mpi module~bem_app_config_particle_runtime->module~bem_types module~bem_app_config_particle_runtime->ieee_arithmetic module~bem_app_config_particle_runtime->module~bem_app_config_types module~bem_app_config_particle_runtime->module~bem_collision module~bem_app_config_particle_runtime->module~bem_config_helpers module~bem_app_config_particle_runtime->module~bem_constants module~bem_app_config_particle_runtime->module~bem_external_boundary_contract module~bem_app_config_particle_runtime->module~bem_string_utils module~bem_app_config_particle_runtime->module~bem_app_config_potential_runtime module~bem_injection bem_injection module~bem_app_config_particle_runtime->module~bem_injection module~bem_app_config_potential_runtime->iso_fortran_env module~bem_app_config_potential_runtime->module~bem_electrostatic_snapshot module~bem_app_config_potential_runtime->module~bem_kinds module~bem_app_config_potential_runtime->module~bem_types module~bem_app_config_potential_runtime->ieee_arithmetic module~bem_app_config_potential_runtime->module~bem_app_config_types module~bem_app_config_potential_runtime->module~bem_config_helpers module~bem_app_config_potential_runtime->module~bem_constants module~bem_app_config_potential_runtime->module~bem_string_utils module~bem_boundary->module~bem_kinds module~bem_boundary->module~bem_types module~bem_boundary->ieee_arithmetic module~bem_config_toml->iso_fortran_env module~bem_config_toml->module~bem_kinds module~bem_config_toml->module~bem_types module~bem_config_toml->ieee_arithmetic module~bem_config_toml->module~bem_app_config_types module~bem_config_toml->module~bem_string_utils module~bem_config_toml->tomlf module~bem_coulomb_fmm_core->module~bem_kinds module~bem_coulomb_fmm_types bem_coulomb_fmm_types module~bem_coulomb_fmm_core->module~bem_coulomb_fmm_types module~bem_injection_flux->module~bem_kinds module~bem_injection_flux->ieee_arithmetic module~bem_injection_flux->module~bem_constants module~bem_injection_flux->module~bem_injection_geometry module~bem_injection_random bem_injection_random module~bem_injection_flux->module~bem_injection_random module~bem_injection_geometry->module~bem_kinds module~bem_injection_geometry->module~bem_string_utils module~bem_matching_plane_contract->module~bem_kinds module~bem_panel_self_terms->module~bem_kinds module~bem_panel_self_terms->module~bem_panel_geometry module~bem_pusher->module~bem_kinds module~bem_sheath_model_core->module~bem_kinds module~bem_sheath_model_core->ieee_arithmetic module~bem_sheath_model_core->module~bem_constants module~bem_app_config_authoring_types->module~bem_kinds module~bem_app_config_authoring_types->module~bem_app_config_types module~bem_coulomb_fmm_types->module~bem_kinds module~bem_coulomb_fmm_types->module~bem_panel_geometry module~bem_coulomb_fmm_types->module~bem_periodic_zero_mode_plan module~bem_importers->module~bem_kinds module~bem_importers->module~bem_mesh module~bem_importers->module~bem_types module~bem_injection->module~bem_injection_flux module~bem_injection->module~bem_injection_geometry module~bem_injection->module~bem_injection_random module~bem_injection_velocity_grid bem_injection_velocity_grid module~bem_injection->module~bem_injection_velocity_grid module~bem_photoelectron_injection bem_photoelectron_injection module~bem_injection->module~bem_photoelectron_injection module~bem_injection_random->module~bem_kinds module~bem_injection_random->module~bem_types module~bem_injection_random->module~bem_constants module~bem_particles bem_particles module~bem_injection_random->module~bem_particles module~bem_panel_surface_sides->module~bem_kinds module~bem_panel_surface_sides->module~bem_types module~bem_panel_surface_sides->module~bem_string_utils module~bem_templates->module~bem_kinds module~bem_templates->module~bem_mesh module~bem_templates->module~bem_types module~bem_injection_velocity_grid->module~bem_kinds module~bem_injection_velocity_grid->ieee_arithmetic module~bem_injection_velocity_grid->module~bem_string_utils module~bem_injection_velocity_grid->module~bem_injection_geometry module~bem_particles->module~bem_kinds module~bem_particles->module~bem_types module~bem_photoelectron_injection->iso_fortran_env module~bem_photoelectron_injection->module~bem_kinds module~bem_photoelectron_injection->module~bem_types module~bem_photoelectron_injection->module~bem_collision module~bem_photoelectron_injection->module~bem_constants module~bem_photoelectron_injection->module~bem_string_utils module~bem_photoelectron_injection->module~bem_boundary module~bem_photoelectron_injection->module~bem_injection_flux module~bem_photoelectron_injection->module~bem_injection_geometry module~bem_photoelectron_injection->module~bem_injection_random

設定読込・メッシュ生成・粒子初期化・シミュレーション実行・結果出力を順に行うCLIエントリーポイント。


Calls

program~~main~~CallsGraph program~main main interface~open_history_writer open_history_writer program~main->interface~open_history_writer interface~open_matching_plane_history_writer open_matching_plane_history_writer program~main->interface~open_matching_plane_history_writer interface~open_potential_history_writer open_potential_history_writer program~main->interface~open_potential_history_writer interface~open_top_reference_history_writer open_top_reference_history_writer program~main->interface~open_top_reference_history_writer interface~run_absorption_insulator run_absorption_insulator program~main->interface~run_absorption_insulator interface~write_macro_residuals_file write_macro_residuals_file program~main->interface~write_macro_residuals_file interface~write_rng_state_file write_rng_state_file program~main->interface~write_rng_state_file proc~ensure_output_dir ensure_output_dir program~main->proc~ensure_output_dir proc~handle_early_cli handle_early_cli program~main->proc~handle_early_cli proc~load_or_init_run_state load_or_init_run_state program~main->proc~load_or_init_run_state proc~mpi_initialize mpi_initialize program~main->proc~mpi_initialize proc~mpi_is_root mpi_is_root program~main->proc~mpi_is_root proc~mpi_shutdown mpi_shutdown program~main->proc~mpi_shutdown proc~mpi_world_barrier mpi_world_barrier program~main->proc~mpi_world_barrier proc~mpi_world_size mpi_world_size program~main->proc~mpi_world_size proc~perf_configure_from_env perf_configure_from_env program~main->proc~perf_configure_from_env proc~perf_region_begin perf_region_begin program~main->proc~perf_region_begin proc~perf_region_end perf_region_end program~main->proc~perf_region_end proc~perf_set_output_context perf_set_output_context program~main->proc~perf_set_output_context proc~perf_write_outputs perf_write_outputs program~main->proc~perf_write_outputs proc~print_run_summary print_run_summary program~main->proc~print_run_summary proc~publish_checkpoint_manifest publish_checkpoint_manifest program~main->proc~publish_checkpoint_manifest proc~write_result_files write_result_files program~main->proc~write_result_files proc~create_directories create_directories proc~ensure_output_dir->proc~create_directories proc~default_app_config default_app_config proc~handle_early_cli->proc~default_app_config proc~load_app_config load_app_config proc~handle_early_cli->proc~load_app_config proc~load_or_init_run_state->proc~mpi_is_root none~initialize~2 matching_plane_response_provider_type%initialize proc~load_or_init_run_state->none~initialize~2 proc~build_mesh_from_config build_mesh_from_config proc~load_or_init_run_state->proc~build_mesh_from_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_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~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~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~lower_ascii lower_ascii proc~perf_configure_from_env->proc~lower_ascii proc~perf_configure perf_configure proc~perf_configure_from_env->proc~perf_configure proc~perf_wall_time_seconds perf_wall_time_seconds proc~perf_region_begin->proc~perf_wall_time_seconds proc~perf_add_elapsed perf_add_elapsed proc~perf_region_end->proc~perf_add_elapsed proc~perf_region_end->proc~perf_wall_time_seconds proc~perf_write_outputs->proc~mpi_is_root proc~mpi_allreduce_max_real_dp_array mpi_allreduce_max_real_dp_array proc~perf_write_outputs->proc~mpi_allreduce_max_real_dp_array proc~mpi_allreduce_min_real_dp_array mpi_allreduce_min_real_dp_array proc~perf_write_outputs->proc~mpi_allreduce_min_real_dp_array proc~mpi_allreduce_sum_i32_array mpi_allreduce_sum_i32_array proc~perf_write_outputs->proc~mpi_allreduce_sum_i32_array proc~mpi_allreduce_sum_real_dp_array mpi_allreduce_sum_real_dp_array proc~perf_write_outputs->proc~mpi_allreduce_sum_real_dp_array proc~mpi_get_rank_size mpi_get_rank_size proc~perf_write_outputs->proc~mpi_get_rank_size proc~atomic_rename atomic_rename proc~publish_checkpoint_manifest->proc~atomic_rename proc~write_result_files->proc~ensure_output_dir proc~begin_checkpoint_publish begin_checkpoint_publish proc~write_result_files->proc~begin_checkpoint_publish proc~begin_checkpoint_publish->proc~atomic_rename proc~build_mesh_from_config->proc~lower_ascii proc~apply_obj_transform apply_obj_transform proc~build_mesh_from_config->proc~apply_obj_transform proc~apply_panel_surface_config apply_panel_surface_config proc~build_mesh_from_config->proc~apply_panel_surface_config 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~surface_model_id_from_name surface_model_id_from_name proc~build_mesh_from_config->proc~surface_model_id_from_name proc~normalize_legacy_physics_config normalize_legacy_physics_config proc~default_app_config->proc~normalize_legacy_physics_config proc~load_app_config->proc~lower_ascii 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 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~2 charge_ledger_type%init proc~load_restart_checkpoint->none~init~2 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~perf_reset perf_reset proc~perf_configure->proc~perf_reset 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_latest_checkpoint_dir->proc~inspect_checkpoint_directory proc~resolve_parallel_rank_size~2 resolve_parallel_rank_size proc~seed_particles_from_config->proc~resolve_parallel_rank_size~2 proc~seed_rng seed_rng proc~seed_particles_from_config->proc~seed_rng none~reset charge_ledger_type%reset none~init~2->none~reset proc~init_mesh init_mesh proc~apply_obj_transform->proc~init_mesh proc~resolve_panel_surface_sides resolve_panel_surface_sides proc~apply_panel_surface_config->proc~resolve_panel_surface_sides 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~inspect_checkpoint_directory->proc~checkpoint_schema_is_loadable 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 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 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~resolve_parallel_rank_size~2->proc~mpi_get_rank_size proc~resolve_periodic2_collision_config~2->proc~lower_ascii 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~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_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~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~derive_field_panel_config->proc~lower_ascii proc~init_mesh->proc~update_mesh_geometry 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~resolve_panel_surface_sides->proc~lower_ascii 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~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~stop_config_error stop_config_error proc~require_toml_success->proc~stop_config_error 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

Variables

Type Attributes Name Initial
type(mesh_type) :: mesh
type(app_config) :: app
type(sim_stats) :: stats
type(sim_stats) :: initial_stats
type(injection_state) :: inject_state
type(charge_ledger_type) :: charge_ledger
type(electrostatic_diagnostics_type) :: electrostatic_diagnostics
type(mpi_context) :: mpi
integer :: history_unit
integer :: potential_history_unit
integer :: top_reference_history_unit
integer :: matching_plane_history_unit
logical :: history_opened
logical :: potential_history_opened
logical :: top_reference_history_opened
logical :: matching_plane_history_opened
logical :: resumed
real(kind=dp) :: perf_t0
real(kind=dp) :: perf_program_t0
real(kind=dp), allocatable :: mesh_potential_v(:)

Subroutines

subroutine handle_early_cli()

MPI 初期化や計算状態の構築前に完結する CLI option を処理する。

Arguments

None

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

subroutine resolve_config_path(path, found)

実行時設定ファイルの読み込みパスを決定する。

Arguments

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

読み込む設定ファイルパス(未検出時は空文字)。

logical, intent(out) :: found

設定ファイルが解決できた場合に .true.

subroutine initialize_injection_state(state, n_species)

種数に合わせて注入状態をゼロ初期化する。

Arguments

Type IntentOptional Attributes Name
type(injection_state), intent(out) :: state

初期化する注入状態。

integer, intent(in) :: n_species

粒子種数(source残差と6面boundary流入残差の種方向配列長)。

Source Code

program main
  use, intrinsic :: iso_fortran_env, only: error_unit
  use bem_kinds, only: dp, i32
  use bem_version, only: beach_build_info, beach_version
  use bem_types, only: sim_stats, mesh_type, injection_state
  use bem_mpi, only: mpi_context, mpi_initialize, mpi_shutdown, mpi_is_root, mpi_world_barrier, mpi_world_size
  use bem_performance_profile, only: perf_configure_from_env, perf_set_output_context, perf_region_begin, &
                                     perf_region_end, perf_write_outputs, perf_region_program_total, perf_region_load_or_init, &
                                     perf_region_history_open, perf_region_write_results, perf_region_write_checkpoint
  use bem_simulator, only: run_absorption_insulator
  use bem_restart, only: load_restart_checkpoint, write_rng_state_file, write_macro_residuals_file
  use bem_periodic_checkpoint, only: resolve_latest_checkpoint_dir
  use bem_checkpoint_contract, only: publish_checkpoint_manifest
  use bem_output_writer, only: open_history_writer, open_potential_history_writer, open_top_reference_history_writer, &
                               open_matching_plane_history_writer, print_run_summary, write_result_files, ensure_output_dir
  use bem_app_config, only: app_config, default_app_config, load_app_config, build_mesh_from_config, &
                            seed_particles_from_config
  use bem_mesh, only: prepare_periodic2_collision_mesh
  use bem_charge_ledger, only: charge_ledger_type
  use bem_electrostatic_snapshot, only: electrostatic_diagnostics_type
  use bem_matching_plane_response_provider, only: matching_plane_response_provider_type, &
                                                  matching_plane_provider_ok
  implicit none

  type(mesh_type) :: mesh
  type(app_config) :: app
  type(sim_stats) :: stats
  type(sim_stats) :: initial_stats
  type(injection_state) :: inject_state
  type(charge_ledger_type) :: charge_ledger
  type(electrostatic_diagnostics_type) :: electrostatic_diagnostics
  type(mpi_context) :: mpi
  integer :: history_unit
  integer :: potential_history_unit
  integer :: top_reference_history_unit
  integer :: matching_plane_history_unit
  logical :: history_opened, potential_history_opened, top_reference_history_opened, matching_plane_history_opened, resumed
  real(dp) :: perf_t0, perf_program_t0
  real(dp), allocatable :: mesh_potential_v(:)

  call handle_early_cli()

  call perf_configure_from_env()
  call perf_region_begin(perf_region_program_total, perf_program_t0)
  call mpi_initialize(mpi)
  call perf_region_begin(perf_region_load_or_init, perf_t0)
  call load_or_init_run_state(app, mesh, initial_stats, inject_state, charge_ledger, resumed, mpi)
  call perf_region_end(perf_region_load_or_init, perf_t0)
  call perf_set_output_context(trim(app%output_dir), app%write_output)
  if (mpi_is_root(mpi)) then
    call perf_region_begin(perf_region_history_open, perf_t0)
    call open_history_writer(app, resumed, history_opened, history_unit)
    call open_potential_history_writer(app, resumed, potential_history_opened, potential_history_unit)
    call open_top_reference_history_writer( &
      app, resumed, top_reference_history_opened, top_reference_history_unit &
      )
    call open_matching_plane_history_writer( &
      app, resumed, matching_plane_history_opened, matching_plane_history_unit &
      )
    call perf_region_end(perf_region_history_open, perf_t0)
  else
    history_opened = .false.
    history_unit = -1
    potential_history_opened = .false.
    potential_history_unit = -1
    top_reference_history_opened = .false.
    top_reference_history_unit = -1
    matching_plane_history_opened = .false.
    matching_plane_history_unit = -1
  end if

  if (history_opened) then
    if (app%write_mesh_potential) then
      if (potential_history_opened) then
        call run_absorption_insulator( &
          mesh, app, stats, history_unit=history_unit, history_stride=app%history_stride, initial_stats=initial_stats, &
          inject_state=inject_state, mpi=mpi, mesh_potential_v=mesh_potential_v, &
          potential_history_unit=potential_history_unit, &
          top_reference_history_unit=top_reference_history_unit, charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      else
        call run_absorption_insulator( &
          mesh, app, stats, history_unit=history_unit, history_stride=app%history_stride, initial_stats=initial_stats, &
          inject_state=inject_state, mpi=mpi, mesh_potential_v=mesh_potential_v, charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      end if
    else
      if (potential_history_opened) then
        call run_absorption_insulator( &
          mesh, app, stats, history_unit=history_unit, history_stride=app%history_stride, initial_stats=initial_stats, &
          inject_state=inject_state, mpi=mpi, &
          potential_history_unit=potential_history_unit, &
          top_reference_history_unit=top_reference_history_unit, charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      else
        call run_absorption_insulator( &
          mesh, app, stats, history_unit=history_unit, history_stride=app%history_stride, initial_stats=initial_stats, &
          inject_state=inject_state, mpi=mpi, charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      end if
    end if
    close (history_unit)
  else
    if (app%write_mesh_potential) then
      if (potential_history_opened) then
        call run_absorption_insulator( &
          mesh, app, stats, initial_stats=initial_stats, inject_state=inject_state, mpi=mpi, &
          mesh_potential_v=mesh_potential_v, &
          potential_history_unit=potential_history_unit, &
          top_reference_history_unit=top_reference_history_unit, charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      else
        call run_absorption_insulator( &
          mesh, app, stats, initial_stats=initial_stats, inject_state=inject_state, mpi=mpi, &
          mesh_potential_v=mesh_potential_v, charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      end if
    else
      if (potential_history_opened) then
        call run_absorption_insulator( &
          mesh, app, stats, initial_stats=initial_stats, inject_state=inject_state, mpi=mpi, &
          potential_history_unit=potential_history_unit, &
          top_reference_history_unit=top_reference_history_unit, charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      else
        call run_absorption_insulator( &
          mesh, app, stats, initial_stats=initial_stats, inject_state=inject_state, mpi=mpi, &
          charge_ledger=charge_ledger, electrostatic_diagnostics=electrostatic_diagnostics, &
          matching_plane_history_unit=matching_plane_history_unit &
          )
      end if
    end if
  end if
  if (potential_history_opened) close (potential_history_unit)
  if (top_reference_history_opened) close (top_reference_history_unit)
  if (matching_plane_history_opened) close (matching_plane_history_unit)

  if (mpi_is_root(mpi)) call print_run_summary(mesh, stats)

  if (app%write_output) then
    call ensure_output_dir(app%output_dir)
    if (mpi_is_root(mpi)) then
      call perf_region_begin(perf_region_write_results, perf_t0)
      if (allocated(mesh_potential_v)) then
        call write_result_files( &
          trim(app%output_dir), mesh, stats, app, mpi_world_size=mpi_world_size(mpi), mesh_potential_v=mesh_potential_v, &
          charge_ledger=charge_ledger, electrostatic_diagnostics=electrostatic_diagnostics &
          )
      else
        call write_result_files( &
          trim(app%output_dir), mesh, stats, app, mpi_world_size=mpi_world_size(mpi), charge_ledger=charge_ledger, &
          electrostatic_diagnostics=electrostatic_diagnostics &
          )
      end if
      call perf_region_end(perf_region_write_results, perf_t0)
    end if
    ! rootが旧完了manifestを無効化してから、全rankでrestart stateの公開へ進む。
    call mpi_world_barrier(mpi)
    call perf_region_begin(perf_region_write_checkpoint, perf_t0)
    call write_rng_state_file(trim(app%output_dir), mpi=mpi)
    call write_macro_residuals_file(trim(app%output_dir), inject_state, mpi=mpi)
    call mpi_world_barrier(mpi)
    if (mpi_is_root(mpi)) then
      call publish_checkpoint_manifest( &
        trim(app%output_dir), stats%batches, mpi_world_size(mpi), allocated(inject_state%macro_residual), .true. &
        )
    end if
    call mpi_world_barrier(mpi)
    call perf_region_end(perf_region_write_checkpoint, perf_t0)
    if (mpi_is_root(mpi)) print '(a,a)', 'results written to ', trim(app%output_dir)
  end if
  call perf_region_end(perf_region_program_total, perf_program_t0)
  call perf_write_outputs(mpi)
  call mpi_shutdown(mpi)

contains

  !> MPI 初期化や計算状態の構築前に完結する CLI option を処理する。
  subroutine handle_early_cli()
    character(len=256) :: arg
    character(len=:), allocatable :: config_path
    integer :: path_length

    if (command_argument_count() < 1) return
    call get_command_argument(1, arg)
    select case (trim(arg))
    case ('--version', '-V')
      print '(a)', trim(beach_version)
      stop
    case ('--build-info')
      print '(a)', beach_build_info
      stop
    case ('--check-config')
      if (command_argument_count() /= 2) error stop 'usage: beach --check-config beach.toml'
      call get_command_argument(2, length=path_length)
      allocate (character(len=path_length) :: config_path)
      call get_command_argument(2, config_path)
      call default_app_config(app)
      call load_app_config(config_path, app)
      print '(a,a)', 'config=', config_path
      print '(a)', 'checks=toml,semantic'
      print '(a)', 'status=ok'
      stop
    case ('--help', '-h')
      print '(a)', 'usage: beach [beach.toml]'
      print '(a)', '       beach --check-config beach.toml'
      print '(a)', '       beach --version'
      print '(a)', '       beach --build-info'
      stop
    end select
  end subroutine handle_early_cli

  !> 設定読込・メッシュ構築・再開判定・乱数初期化をまとめて行う。
  !! @param[out] app 読み込み・既定値適用後のアプリ設定。
  !! @param[out] mesh 構築した三角形メッシュ。
  !! @param[out] initial_stats 再開時に引き継ぐ初期統計(新規実行時はゼロ)。
  !! @param[out] inject_state 種別ごとの注入残差状態。
  !! @param[out] resumed チェックポイントから再開した場合に `.true.`。
  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
    character(len=512) :: matching_response_message
    integer(i32) :: matching_response_status
    logical :: has_config
    type(matching_plane_response_provider_type) :: matching_response_provider

    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 matching_response_provider%initialize( &
      app, mpi, matching_response_status, matching_response_message &
      )
    if (matching_response_status /= matching_plane_provider_ok) then
      error stop 'matching-plane response preflight failed: '//trim(matching_response_message)
    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
      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

  !> 実行時設定ファイルの読み込みパスを決定する。
  !! @param[out] path 読み込む設定ファイルパス(未検出時は空文字)。
  !! @param[out] found 設定ファイルが解決できた場合に `.true.`。
  subroutine resolve_config_path(path, found)
    character(len=*), intent(out) :: path
    logical, intent(out) :: found
    logical :: has_primary
    character(len=*), parameter :: primary_config = 'beach.toml'

    path = ''
    found = .false.
    if (command_argument_count() >= 1) then
      call get_command_argument(1, path)
      if (len_trim(path) == 0) error stop 'Config path argument is empty.'
      found = .true.
      return
    end if

    inquire (file=primary_config, exist=has_primary)
    if (has_primary) then
      path = primary_config
      found = .true.
    end if
  end subroutine resolve_config_path

  !> 種数に合わせて注入状態をゼロ初期化する。
  !! @param[out] state 初期化する注入状態。
  !! @param[in] n_species 粒子種数(source残差と6面boundary流入残差の種方向配列長)。
  subroutine initialize_injection_state(state, n_species)
    type(injection_state), intent(out) :: state
    integer, intent(in) :: n_species

    allocate (state%macro_residual(n_species))
    allocate (state%boundary_macro_residual(6, n_species))
    state%macro_residual = 0.0d0
    state%boundary_macro_residual = 0.0d0
  end subroutine initialize_injection_state

end program main