da_llxy_default.inc
References to this file elsewhere.
1 subroutine da_llxy_default (xlati,xloni,x,y)
2
3 !----------------------------------------------------------------------------
4 ! Purpose: calculates the (x,y) location (dot) in the mesoscale grids
5 ! ------- from latitudes and longitudes
6 !
7 ! for global domain co-ordinates
8 !
9 ! input:
10 ! -----
11 ! xlat: latitudes
12 ! xlon: longitudes
13 !
14 ! output:
15 ! -----
16 ! x: the coordinate in x (i)-direction.
17 ! y: the coordinate in y (j)-direction.
18 !
19 !----------------------------------------------------------------------------
20
21 implicit none
22
23 real, intent(in) :: xlati, xloni
24 real, intent(out) :: x, y
25
26 real :: dxlon
27 real :: xlat, xlon
28 real :: xx, yy, xc, yc
29 real :: cell, psi0, psx, r, flp
30 real :: centri, centrj
31 real :: ratio
32 real :: bb
33 real, parameter :: conv = 180.0 / pi
34
35 if (trace_use_frequent) call da_trace_entry("da_llxy_default")
36
37 xlon = xloni
38 xlat = xlati
39
40 xlat = max (xlat, -89.95)
41 xlat = min (xlat, +89.95)
42
43 dxlon = xlon - xlonc
44 if (dxlon > 180) dxlon = dxlon - 360.0
45 if (dxlon < -180) dxlon = dxlon + 360.0
46
47 if (map_projection == 3) then
48 xc = 0.0
49 yc = YCNTR
50
51 cell = cos(xlat/conv)/(1.0+sin(xlat/conv))
52 yy = -c2*alog(cell)
53 xx = c2*dxlon/conv
54 else
55 psi0 = (pole - phic)/conv
56 xc = 0.0
57
58 ! calculate x,y coords. relative to pole
59
60 flp = cone_factor*dxlon/conv
61
62 psx = (pole - xlat)/conv
63
64 if (map_projection == 2) then
65 ! Polar stereographics:
66 bb = 2.0*(cos(psi1/2.0)**2)
67 yc = -earth_radius*bb*tan(psi0/2.0)
68 r = -earth_radius*bb*tan(psx/2.0)
69 else
70 ! Lambert conformal:
71 bb = -earth_radius/cone_factor*sin(psi1)
72 yc = bb*(tan(psi0/2.0)/tan(psi1/2.0))**cone_factor
73 r = bb*(tan(psx /2.0)/tan(psi1/2.0))**cone_factor
74 end if
75
76 if (phic < 0.0) then
77 xx = r*sin(flp)
78 yy = r*cos(flp)
79 else
80 xx = -r*sin(flp)
81 yy = r*cos(flp)
82 end if
83
84 end if
85
86 ! transform (1,1) to the origin
87 ! the location of the center in the coarse domain
88
89 centri = real (coarse_ix + 1)/2.0
90 centrj = real (coarse_jy + 1)/2.0
91
92 ! the (x,y) coordinates in the coarse domain
93
94 x = (xx - xc)/coarse_ds + centri
95 y = (yy - yc)/coarse_ds + centrj
96
97 ratio = coarse_ds / dsm
98
99 ! only add 0.5 so that x/y is relative to first cross points:
100
101 x = (x - start_x)*ratio + 0.5
102 y = (y - start_y)*ratio + 0.5
103
104 if (trace_use_frequent) call da_trace_exit("da_llxy_default")
105
106 end subroutine da_llxy_default
107
108