allocate_particles Subroutine

public subroutine allocate_particles(pcls, n)

粒子数に一致するSoA領域を確保する。位置・速度・電荷・質量は呼出し元で埋める。 重みは1、粒子種IDは0、放出元は-1、aliveはtrueで初期化する。

Arguments

Type IntentOptional Attributes Name
type(particles_soa), intent(out) :: pcls
integer(kind=i32), intent(in) :: n

Called by

proc~~allocate_particles~~CalledByGraph proc~allocate_particles allocate_particles proc~init_particles init_particles proc~init_particles->proc~allocate_particles proc~init_random_beam_particles init_random_beam_particles proc~init_random_beam_particles->proc~allocate_particles

Source Code

  subroutine allocate_particles(pcls, n)
    type(particles_soa), intent(out) :: pcls
    integer(i32), intent(in) :: n

    if (n < 0_i32) error stop "n must be non-negative"
    pcls%n = n
    allocate (pcls%x(3, n), pcls%v(3, n), pcls%q(n), pcls%m(n), pcls%w(n), &
              pcls%species_id(n), pcls%source_element(n), pcls%alive(n))
    pcls%w = 1.0_dp
    pcls%species_id = 0_i32
    pcls%source_element = -1_i32
    pcls%alive = .true.
  end subroutine allocate_particles