直方体領域 [low, high] 内で一様分布の初期位置をサンプリングする。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | low(3) | |||
| real(kind=dp), | intent(in) | :: | high(3) | |||
| real(kind=dp), | intent(out) | :: | x(:,:) |
subroutine sample_uniform_positions(low, high, x) real(dp), intent(in) :: low(3), high(3) real(dp), intent(out) :: x(:, :) real(dp) :: span(3) integer :: i if (size(x, 1) /= 3) error stop "x first dimension must be 3" if (any(high < low)) error stop "high must be >= low for all axes" span = high - low call random_number(x) do i = 1, size(x, 2) x(:, i) = low + span*x(:, i) end do end subroutine sample_uniform_positions