-
Notifications
You must be signed in to change notification settings - Fork 14
/
llxy_module.F90
218 lines (185 loc) · 7.71 KB
/
llxy_module.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! MODULE LLXY_MODULE
!
! This module handles transformations between model grid coordinates and
! latitude-longitude coordinates. The actual transformations are done through
! the map_utils module.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module llxy_module
use program_setup
use map_utils_mod
use utils_mod
use misc_definitions_module
! Parameters
integer, parameter :: MAX_SOURCE_LEVELS = 20
! Variables
integer :: current_nest_number
integer :: SOURCE_PROJ = 0
! The following arrays hold values for all available domains
! NOTE: The entries in the arrays for "domain 0" are used for projection
! information of user-specified source data
type (proj_info) :: proj_stack
! The projection and domain that we have computed constants for
integer :: computed_proj = INVALID
integer :: computed_domain = INVALID
contains
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Name: push_source_projection
!
! Purpose:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine push_source_projection(iprojection, user_stand_lon, user_truelat1, user_truelat2, &
user_dxkm, user_dykm, user_dlat, user_dlon, user_known_x, &
user_known_y, user_known_lat, user_known_lon, &
user_pole_lat, user_pole_lon, &
user_centerlat, user_centerlon, &
user_centeri, user_centerj, &
earth_radius)
implicit none
! Arguments
integer, intent(in) :: iprojection
real, intent(in) :: user_stand_lon, user_truelat1, user_truelat2, user_dxkm, user_dykm, &
user_dlat, user_dlon, &
user_known_x, user_known_y, user_known_lat, user_known_lon
real, intent(in), optional :: earth_radius
real, intent(in), optional :: user_centerlon, user_centerlat, user_pole_lat, user_pole_lon
real, intent(in), optional :: user_centerj, user_centeri
call map_init(proj_stack)
if (iprojection == PROJ_LATLON) then
call map_set(iprojection, proj_stack, &
lat1=user_known_lat, &
lon1=user_known_lon, &
knowni=user_known_x, &
knownj=user_known_y, &
nxmax=nint(360.0 / user_dlon), &
latinc=user_dlat, &
loninc=user_dlon, &
r_earth=earth_radius)
else if (iprojection == PROJ_MERC) then
call map_set(iprojection, proj_stack, &
truelat1=user_truelat1, &
lat1=user_known_lat, &
lon1=user_known_lon, &
knowni=user_known_x, &
knownj=user_known_y, &
dx=user_dxkm, &
r_earth=earth_radius)
else if (iprojection == PROJ_CYL) then
call error_handler('Should not have PROJ_CYL as projection for ' &
//'target data in push_source_projection().',ERROR_CODE)
else if (iprojection == PROJ_CASSINI) then
call map_set(iprojection, proj_stack, &
latinc=user_dlat, &
loninc=user_dlon, &
stdlon=user_stand_lon, &
lat1=user_centerlat, &
lon1=user_centerlon, &
lat0=user_pole_lat, &
lon0=user_pole_lon, &
knowni=user_centeri, &
knownj=user_centerj, &
r_earth=earth_radius)
else if (iprojection == PROJ_LC) then
call map_set(iprojection, proj_stack, &
truelat1=user_truelat1, &
truelat2=user_truelat2, &
stdlon=user_stand_lon, &
lat1=user_known_lat, &
lon1=user_known_lon, &
knowni=user_known_x, &
knownj=user_known_y, &
dx=user_dxkm, &
r_earth=earth_radius)
else if (iprojection == PROJ_ALBERS_NAD83) then
call map_set(iprojection, proj_stack, &
truelat1=user_truelat1, &
truelat2=user_truelat2, &
stdlon=user_stand_lon, &
lat1=user_known_lat, &
lon1=user_known_lon, &
knowni=user_known_x, &
knownj=user_known_y, &
dx=user_dxkm, &
r_earth=earth_radius)
else if (iprojection == PROJ_PS) then
call map_set(iprojection, proj_stack, &
truelat1=user_truelat1, &
stdlon=user_stand_lon, &
lat1=user_known_lat, &
lon1=user_known_lon, &
knowni=user_known_x, &
knownj=user_known_y, &
dx=user_dxkm, &
r_earth=earth_radius)
else if (iprojection == PROJ_PS_WGS84) then
call map_set(iprojection, proj_stack, &
truelat1=user_truelat1, &
stdlon=user_stand_lon, &
lat1=user_known_lat, &
lon1=user_known_lon, &
knowni=user_known_x, &
knownj=user_known_y, &
dx=user_dxkm, &
r_earth=earth_radius)
else if (iprojection == PROJ_GAUSS) then
call map_set(iprojection, proj_stack, &
lat1=user_known_lat, &
lon1=user_known_lon, &
nxmax=nint(360.0 / user_dlon), &
nlat=nint(user_dlat), &
loninc=user_dlon, &
r_earth=earth_radius)
else if (iprojection == PROJ_ROTLL) then
! BUG: Implement this projection.
end if
end subroutine push_source_projection
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Name: lltoxy
!
! Purpose:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine xytoll(x, y, xlat, xlon, stagger, comp_ll)
implicit none
! Arguments
integer, intent(in) :: stagger
real, intent(in) :: x, y
real, intent(out) :: xlat, xlon
logical, optional, intent(in) :: comp_ll
! Local variables
real :: rx, ry
logical :: save_comp_ll
! Account for grid staggering; we cannot modify x and y, so modify local
! copies of them
if (stagger == U) then
rx = x - 0.5
ry = y
else if (stagger == V) then
rx = x
ry = y - 0.5
else if (stagger == HH) then
proj_stack%stagger = HH
rx = x
ry = y
else if (stagger == VV) then
proj_stack%stagger = VV
rx = x
ry = y
else if (stagger == CORNER) then
proj_stack%stagger = CORNER
rx = x - 0.5
ry = y - 0.5
else
rx = x
ry = y
end if
if (present(comp_ll)) then
save_comp_ll = proj_stack%comp_ll
proj_stack%comp_ll = comp_ll
end if
call ij_to_latlon(proj_stack, rx, ry, xlat, xlon)
if (present(comp_ll)) then
proj_stack%comp_ll = save_comp_ll
end if
end subroutine xytoll
end module llxy_module