module compute_electron_density_m !! Compute electron density using communication within species use MPI; use comm_handler_m, only : comm_handler_t use precision_grillix_m, only : GP, MPI_GP use params_zhdanov_species_m, only : params_zhdanov_species_t use mesh_cart_m, only : mesh_cart_t implicit none contains subroutine compute_electron_density(comm_handler, mesh, & params_species, & dens_species) !! Computes electron density via reduction of ion charge density type(comm_handler_t), intent(in) :: comm_handler !! Communicators type(mesh_cart_t), intent(in) :: mesh !! Mesh within poloidal plane type(params_zhdanov_species_t), intent(in) :: params_species !! Species paramters for the Zhdanov model real(GP), dimension(mesh%get_n_points()), intent(inout) :: dens_species !! Species density real(GP), dimension(mesh%get_n_points()) :: charge_dens !! Z-weighted species density integer :: ierr integer :: l ! Reduce Z*ion density on density of electron species !$omp parallel do private(l) do l = 1, mesh%get_n_points() charge_dens(l) = dens_species(l) * params_species%za enddo !$omp end parallel do call MPI_reduce(charge_dens, dens_species, mesh%get_n_points(), & MPI_GP, MPI_SUM, 0, comm_handler%get_comm_species(), ierr) end subroutine end module