1 subroutine lltoxy(lat,lon,rx,ry,stagger)
6 integer, intent(in) :: stagger
7 real, intent(in) :: lat, lon
8 real, intent(out) :: rx, ry
11 real :: dphd,dlmd !Grid increments, degrees
12 integer :: ii,imt,jj,jmt,k,krows,ncol,nrow
13 real :: glatd !Geographic latitude, positive north
14 real :: glond !Geographic longitude, positive west
15 real :: col,d1,d2,d2r,dlm,dlm1,dlm2,dph,glat,glon, &
16 pi,r2d,row,tlat,tlat1,tlat2, &
17 tlon,tlon1,tlon2,tph0,tlm0,x,y,z
22 dphd = phi/real((jydim(current_nest_number)-1)/2)
23 dlmd = lambda/real(ixdim(current_nest_number)-1)
29 imt = 2*ixdim(current_nest_number)-1
30 jmt = jydim(current_nest_number)/2+1
39 x = cos(tph0)*cos(glat)*cos(glon-tlm0)+sin(tph0)*sin(glat)
40 y = -cos(glat)*sin(glon-tlm0)
41 z = cos(tph0)*sin(glat)-sin(tph0)*cos(glat)*cos(glon-tlm0)
42 tlat = r2d*atan(z/sqrt(x*x+y*y))
46 col = tlon/dlmd+ixdim(current_nest_number)
52 if (stagger == HH) then
54 if ((mod(nrow,2) == 1 .and. mod(ncol,2) == 1) .or. &
55 (mod(nrow,2) == 0 .and. mod(ncol,2) == 0)) then
56 tlat1 = (nrow-jmt)*dph
58 tlon1 = (ncol-ixdim(current_nest_number))*dlm
62 d1 = acos(cos(tlat)*cos(tlat1)*cos(dlm1)+sin(tlat)*sin(tlat1))
63 d2 = acos(cos(tlat)*cos(tlat2)*cos(dlm2)+sin(tlat)*sin(tlat2))
71 tlat1 = (nrow+1-jmt)*dph
73 tlon1 = (ncol-ixdim(current_nest_number))*dlm
77 d1 = acos(cos(tlat)*cos(tlat1)*cos(dlm1)+sin(tlat)*sin(tlat1))
78 d2 = acos(cos(tlat)*cos(tlat2)*cos(dlm2)+sin(tlat)*sin(tlat2))
87 else if (stagger == VV) then
89 if ((mod(nrow,2) == 0 .and. mod(ncol,2) == 1) .or. &
90 (mod(nrow,2) == 1 .and. mod(ncol,2) == 0)) then
91 tlat1 = (nrow-jmt)*dph
93 tlon1 = (ncol-ixdim(current_nest_number))*dlm
97 d1 = acos(cos(tlat)*cos(tlat1)*cos(dlm1)+sin(tlat)*sin(tlat1))
98 d2 = acos(cos(tlat)*cos(tlat2)*cos(dlm2)+sin(tlat)*sin(tlat2))
106 tlat1 = (nrow+1-jmt)*dph
108 tlon1 = (ncol-ixdim(current_nest_number))*dlm
112 d1 = acos(cos(tlat)*cos(tlat1)*cos(dlm1)+sin(tlat)*sin(tlat1))
113 d2 = acos(cos(tlat)*cos(tlat2)*cos(dlm2)+sin(tlat)*sin(tlat2))
125 if (stagger == HH) then
126 if (mod(jj,2) == 1) ii = ii+1
127 krows = ((nrow-1)/2)*imt
128 if (mod(nrow,2) == 1) then
131 k = krows+ixdim(current_nest_number)+ncol/2
134 else if (stagger == VV) then
135 if (mod(jj,2) == 0) ii=ii+1
137 krows = ((nrow-1)/2)*imt
138 if (mod(nrow,2) == 1) then
141 k = krows+ixdim(current_nest_number)-1+(ncol+1)/2
148 end subroutine lltoxy