Run distributed MBE calculation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mbe_context_t), | intent(inout) | :: | this | |||
| type(json_output_data_t), | intent(out), | optional | :: | json_data |
subroutine mbe_run_distributed(this, json_data) !! Run distributed MBE calculation use mqc_mbe_fragment_distribution_scheme, only: global_coordinator, node_coordinator, node_worker use pic_logger, only: logger => global_logger use pic_io, only: to_char use omp_lib, only: omp_set_num_threads, omp_get_max_threads class(mbe_context_t), intent(inout) :: this type(json_output_data_t), intent(out), optional :: json_data if (.not. this%has_mpi()) then call logger%error("mbe_run_distributed: resources not set in context") return end if ! Determine role based on MPI rank if (this%resources%mpi_comms%world_comm%leader() .and. & this%resources%mpi_comms%node_comm%leader()) then ! Global coordinator (rank 0, node leader on node 0) call omp_set_num_threads(omp_get_max_threads()) call logger%verbose("Rank 0: Acting as global coordinator") if (this%has_geometry()) then call global_coordinator(this%resources, this%total_fragments, this%polymers, & this%max_level, this%node_leader_ranks, this%num_nodes, & this%sys_geom, this%method_config, this%calc_type, json_data) else call global_coordinator(this%resources, this%total_fragments, this%polymers, & this%max_level, this%node_leader_ranks, this%num_nodes, & method_config=this%method_config, calc_type=this%calc_type, & json_data=json_data) end if else if (this%resources%mpi_comms%node_comm%leader()) then ! Node coordinator (node leader on other nodes) call logger%verbose("Rank "//to_char(this%resources%mpi_comms%world_comm%rank())// & ": Acting as node coordinator") call node_coordinator(this%resources, this%method_config, this%calc_type) else ! Worker call omp_set_num_threads(1) call logger%verbose("Rank "//to_char(this%resources%mpi_comms%world_comm%rank())// & ": Acting as worker") if (this%has_geometry()) then call node_worker(this%resources, this%sys_geom, this%method_config, this%calc_type) else call node_worker(this%resources, method_config=this%method_config, & calc_type=this%calc_type) end if end if end subroutine mbe_run_distributed