15 SUBROUTINE find_limit (p1_in, p2_in, latmin, latmax)
16 REAL*8,
INTENT(IN) :: p1_in(2), p2_in(2)
17 REAL*8,
INTENT(OUT) :: latmin, latmax
19 REAL*8 :: p1(2),p2(2), pm(2)
20 REAL*8 :: r2d = 180.0/acos(-1.0)
22 p1 = p1_in/r2d; p2 = p2_in/r2d
23 latmin = min(p1(1), p2(1))
24 latmax = max(p1(1), p2(1))
28 print*,
'before loop', p1(1)*r2d,p2(1)*r2d,pm(1)*r2d
31 DO WHILE (abs(p1(1)-p2(1)) > 0.00001 .AND. &
32 abs(p1(2)-p2(2)) > 0.00001 )
33 IF (abs(p1(1)-pm(1)) < abs(p2(1)-pm(1)))
THEN 40 print*,
'in loop', p1(1)*r2d,p2(1)*r2d, pm(1)*r2d
44 latmin = min(latmin, pm(1))
45 latmax = max(latmax, pm(1))
83 REAL*8,
INTENT(IN) :: p1(2),p2(2)
84 REAL*8,
INTENT(OUT) :: p(2)
87 REAL*8 :: xyz1(3),xyz2(3),xyz(3)
92 xyz1(1) = cos(p1(1)) * cos(p1(2))
93 xyz1(2) = cos(p1(1)) * sin(p1(2))
96 xyz2(1) = cos(p2(1)) * cos(p2(2))
97 xyz2(2) = cos(p2(1)) * sin(p2(2))
105 xyz = 0.5 * (xyz1 + xyz2)
107 xyz = xyz / sqrt(dot_product(xyz,xyz))
110 p(1) = atan2(xyz(3), sqrt(xyz(1) * xyz(1) + xyz(2) * xyz(2)))
111 p(2) = atan2(xyz(2), xyz(1))
113 IF (p(2) < -pi / 2.0)
THEN subroutine find_limit(p1_in, p2_in, latmin, latmax)
Given two points on a cubed-sphere grid, compute the maximum and minimum latitudinal extent of the re...
subroutine middle(p1, p2, p)
Compute the latitude and longitude of the middle point between two given points.