get_distance Subroutine

public pure subroutine get_distance(x, y, d, r)

粒子之间的距离 (distance)

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(2) :: x

两点坐标

real(kind=rk), intent(in), dimension(2) :: y

两点坐标

real(kind=rk), intent(out), dimension(2) :: d

坐标轴距离

real(kind=rk), intent(out) :: r

欧式距离


Contents

Source Code


Source Code

    pure subroutine get_distance(x, y, d, r)
        real(rk), intent(in), dimension(2) :: x, y  !! 两点坐标
        real(rk), intent(out), dimension(2) :: d  !! 坐标轴距离
        real(rk), intent(out) :: r  !! 欧式距离

        d = x - y; r = sqrt(d(1)*d(1) + d(2)*d(2))

    end subroutine get_distance