private subroutine PairDistance(stations)
Compute distance between pairs
Arguments
Variables
Type |
Visibility | Attributes |
|
Name |
| Initial | |
real(kind=float),
|
public |
|
:: |
average |
|
|
|
integer(kind=short),
|
public |
|
:: |
i |
|
|
|
integer(kind=short),
|
public |
|
:: |
j |
|
|
|
Source Code
SUBROUTINE PairDistance &
!
(stations)
IMPLICIT NONE
!Arguments with intent (in):
TYPE (ObservationalNetwork), INTENT(IN) :: stations
!Local declarations
INTEGER (KIND = short) :: i, j
REAL (KIND = float) :: average
!---------------------------end of declarations--------------------------------
!allocate variables
ALLOCATE ( dist_pairs(stations % countObs,stations % countObs))
! Compute distance among stations and experimental variance
average = 0.
dist_pairs = 0.
DO i = 1, stations % countObs
average = average + stations % obs (i) % value
DO j = 1, stations % countObs
IF ( i == j) CYCLE !skip same point pairs, distance is zero
IF ( j < i) CYCLE !this pair is already in the vector; pair(4,2) is the same as pair(2,4)
point1 % northing = stations % obs (i) % xyz % northing
point1 % easting = stations % obs (i) % xyz % easting
point2 % northing = stations % obs (j) % xyz % northing
point2 % easting = stations % obs (j) % xyz % easting
dist_pairs(i,j) = Distance (point1,point2)
END DO
END DO
average = average / stations % countObs
!compute experimental variance
expVar = 0.
DO i = 1, stations % countObs
expVar = expVar + ( stations % obs (i) % value - average ) ** 2.
END DO
expVar = expVar / stations % countObs
RETURN
END SUBROUTINE PairDistance