1 subroutine da_llxy_default (xlati,xloni,x,y)
3 !----------------------------------------------------------------------------
4 ! Purpose: calculates the (x,y) location (dot) in the mesoscale grids
5 ! ------- from latitudes and longitudes
7 ! for global domain co-ordinates
16 ! x: the coordinate in x (i)-direction.
17 ! y: the coordinate in y (j)-direction.
19 !----------------------------------------------------------------------------
23 real, intent(in) :: xlati, xloni
24 real, intent(out) :: x, y
28 real :: xx, yy, xc, yc
29 real :: cell, psi0, psx, r, flp
30 real :: centri, centrj
33 real, parameter :: conv = 180.0 / pi
35 if (trace_use_frequent) call da_trace_entry("da_llxy_default")
40 xlat = max (xlat, -89.95)
41 xlat = min (xlat, +89.95)
44 if (dxlon > 180) dxlon = dxlon - 360.0
45 if (dxlon < -180) dxlon = dxlon + 360.0
47 if (map_projection == 3) then
51 cell = cos(xlat/conv)/(1.0+sin(xlat/conv))
55 psi0 = (pole - phic)/conv
58 ! calculate x,y coords. relative to pole
60 flp = cone_factor*dxlon/conv
62 psx = (pole - xlat)/conv
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)
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
86 ! transform (1,1) to the origin
87 ! the location of the center in the coarse domain
89 centri = real (coarse_ix + 1)/2.0
90 centrj = real (coarse_jy + 1)/2.0
92 ! the (x,y) coordinates in the coarse domain
94 x = (xx - xc)/coarse_ds + centri
95 y = (yy - yc)/coarse_ds + centrj
97 ratio = coarse_ds / dsm
99 ! only add 0.5 so that x/y is relative to first cross points:
101 x = (x - start_x)*ratio + 0.5
102 y = (y - start_y)*ratio + 0.5
104 if (trace_use_frequent) call da_trace_exit("da_llxy_default")
106 end subroutine da_llxy_default