mpi_split_count Function

public function mpi_split_count(total_count, rank, size) result(local_count)

総数 total_count をrankへ均等分割したときの局所個数を返す。

Arguments

Type IntentOptional Attributes Name
integer(kind=i32), intent(in) :: total_count
integer(kind=i32), intent(in) :: rank
integer(kind=i32), intent(in) :: size

Return Value integer(kind=i32)


Called by

proc~~mpi_split_count~~CalledByGraph proc~mpi_split_count mpi_split_count proc~init_particle_batch_from_config init_particle_batch_from_config proc~init_particle_batch_from_config->proc~mpi_split_count

Source Code

  integer(i32) function mpi_split_count(total_count, rank, size) result(local_count)
    integer(i32), intent(in) :: total_count, rank, size
    integer(i32) :: base_count, n_remainder

    if (total_count < 0_i32) error stop 'mpi_split_count requires total_count >= 0.'
    if (size <= 0_i32) error stop 'mpi_split_count requires size > 0.'
    if (rank < 0_i32 .or. rank >= size) error stop 'mpi_split_count rank out of range.'

    base_count = total_count/size
    n_remainder = modulo(total_count, size)
    local_count = base_count
    if (rank < n_remainder) local_count = local_count + 1_i32
  end function mpi_split_count