radiation_task_bounds Subroutine

public subroutine radiation_task_bounds(rad, n_tasks)

Performs contiguous task decomposition for the radiation solver.

Arguments

Type IntentOptional Attributes Name
type(radiation_mpi_t), intent(inout) :: rad

The radiation context to update.

integer, intent(in) :: n_tasks

Total number of discrete tasks (e.g., rays).


Calls

proc~~radiation_task_bounds~~CallsGraph proc~radiation_task_bounds mod_mpi_radiation::radiation_task_bounds proc~fatal_error mod_kinds::fatal_error proc~radiation_task_bounds->proc~fatal_error

Called by

proc~~radiation_task_bounds~~CalledByGraph proc~radiation_task_bounds mod_mpi_radiation::radiation_task_bounds proc~radiation_mpi_initialize mod_mpi_radiation::radiation_mpi_initialize proc~radiation_mpi_initialize->proc~radiation_task_bounds program~lowmach_react_hex lowmach_react_hex program~lowmach_react_hex->proc~radiation_mpi_initialize

Source Code

   subroutine radiation_task_bounds(rad, n_tasks)
      type(radiation_mpi_t), intent(inout) :: rad
      integer, intent(in) :: n_tasks

      integer :: base, rem

      if (n_tasks < 0) call fatal_error('mpi_radiation', 'n_tasks cannot be negative')
      if (rad%nprocs <= 0) call fatal_error('mpi_radiation', 'radiation communicator is not initialized')

      base = n_tasks / rad%nprocs
      rem = mod(n_tasks, rad%nprocs)

      if (rad%rank < rem) then
         rad%nlocal_tasks = base + 1
         rad%first_task = rad%rank * (base + 1) + 1
      else
         rad%nlocal_tasks = base
         rad%first_task = rem * (base + 1) + (rad%rank - rem) * base + 1
      end if
      rad%last_task = rad%first_task + rad%nlocal_tasks - 1
   end subroutine radiation_task_bounds