Line data Source code
1 : !---------------------------------------------------------------------------
2 : ! $Id$
3 : !===============================================================================
4 : module index_mapping
5 :
6 : ! Description:
7 : ! Functions to map back and forth between the PDF arrays and the hydrometeor
8 : ! arrays.
9 :
10 : ! The “iiPDF” indices are used to index all PDF variates, including all
11 : ! hydrometeor variates.
12 : ! The “ii” indices are used to index hydrometeor arrays.
13 : ! The “ii” variates are a subset of the “iiPDF” variates.
14 : ! Conversions between the two sets of indices are done by the
15 : ! functions pdf2hydromet_idx and hydromet2pdf_idx below.
16 : !
17 : ! ------------------------------------------------------------------------
18 : !
19 : ! iiPDF indices:
20 : !
21 : ! Included indices:
22 : ! iiPDF_chi, iiPDF_eta, iiPDF_w, iiPDF_Ncn, iiPDF_rr, & all other hydrometeors
23 : !
24 : ! Number of indices: pdf_dim
25 : !
26 : ! Examples of arrays dimensioned by pdf_dim:
27 : ! mu_x_1_n, corr_array_n_cloud, . . .
28 : !
29 : ! Declared as module variables in module array_index
30 : !
31 : ! Initialized in subroutine setup_pdf_indices
32 : !
33 : ! ----------------------------------------------------------------------
34 : !
35 : ! ii indices:
36 : !
37 : ! Included indices:
38 : ! iirr, iiNr, iiri, iiNi, iirs, iiNs, iirg, iiNg
39 : !
40 : ! Number of indices: hydromet_dim
41 : !
42 : ! Examples of arrays dimensioned by hydromet_dim:
43 : ! hydromet, wphydrometp, . . .
44 : !
45 : ! Declared as module variables in module array_index.
46 : !
47 : ! Initialized in subroutine init_microphys
48 : !
49 : ! -----------------------------------------------------------------------
50 : !
51 : ! References:
52 : ! None
53 : !-------------------------------------------------------------------------
54 :
55 : implicit none
56 :
57 : private ! Default Scope
58 :
59 : public :: pdf2hydromet_idx, &
60 : hydromet2pdf_idx, &
61 : rx2Nx_hm_idx, &
62 : Nx2rx_hm_idx, &
63 : mvr_hm_max
64 :
65 : contains
66 :
67 : !=============================================================================
68 0 : function pdf2hydromet_idx( pdf_idx, hm_metadata ) result( hydromet_idx )
69 :
70 : ! Description:
71 : ! Returns the position of a specific precipitating hydrometeor corresponding
72 : ! to the PDF index (pdf_idx) in the precipitating hydrometeor array
73 : ! (hydromet_idx).
74 :
75 : ! References:
76 : !-----------------------------------------------------------------------
77 :
78 : use corr_varnce_module, only: &
79 : hm_metadata_type
80 :
81 : implicit none
82 :
83 : ! Input Variables
84 : integer, intent(in) :: &
85 : pdf_idx ! Index of a hydrometeor in the PDF array.
86 :
87 : type (hm_metadata_type), intent(in) :: &
88 : hm_metadata
89 :
90 : ! Return Variable
91 : integer :: &
92 : hydromet_idx ! Index of a hydrometeor in the hydromet array.
93 :
94 :
95 : ! Initialize hydromet_idx
96 0 : hydromet_idx = 0
97 :
98 0 : if ( pdf_idx == hm_metadata%iiPDF_rr ) then
99 :
100 : ! Index for rain water mixing ratio, rr.
101 0 : hydromet_idx = hm_metadata%iirr
102 :
103 0 : elseif ( pdf_idx == hm_metadata%iiPDF_Nr ) then
104 :
105 : ! Index for rain drop concentration, Nr.
106 0 : hydromet_idx = hm_metadata%iiNr
107 :
108 0 : elseif ( pdf_idx == hm_metadata%iiPDF_rs ) then
109 :
110 : ! Index for snow mixing ratio, rs.
111 0 : hydromet_idx = hm_metadata%iirs
112 :
113 0 : elseif ( pdf_idx == hm_metadata%iiPDF_Ns ) then
114 :
115 : ! Index for snow flake concentration, Ns.
116 0 : hydromet_idx = hm_metadata%iiNs
117 :
118 0 : elseif ( pdf_idx == hm_metadata%iiPDF_rg ) then
119 :
120 : ! Index for graupel mixing ratio, rg.
121 0 : hydromet_idx = hm_metadata%iirg
122 :
123 0 : elseif ( pdf_idx == hm_metadata%iiPDF_Ng ) then
124 :
125 : ! Index for graupel concentration, Ng.
126 0 : hydromet_idx = hm_metadata%iiNg
127 :
128 0 : elseif ( pdf_idx == hm_metadata%iiPDF_ri ) then
129 :
130 : ! Index for ice mixing ratio, ri.
131 0 : hydromet_idx = hm_metadata%iiri
132 :
133 0 : elseif ( pdf_idx == hm_metadata%iiPDF_Ni ) then
134 :
135 : ! Index for ice concentration, Ni.
136 0 : hydromet_idx = hm_metadata%iiNi
137 :
138 : endif
139 :
140 : return
141 :
142 : end function pdf2hydromet_idx
143 :
144 : !=============================================================================
145 0 : function hydromet2pdf_idx( hydromet_idx, hm_metadata ) result( pdf_idx )
146 :
147 : ! Description:
148 : ! Returns the position of a specific precipitating hydrometeor corresponding
149 : ! to the precipitating hydrometeor index (hydromet_idx) in the PDF array
150 : ! (pdf_idx).
151 :
152 : ! References:
153 : !-----------------------------------------------------------------------
154 :
155 : use corr_varnce_module, only: &
156 : hm_metadata_type
157 :
158 : implicit none
159 :
160 : ! Input Variable
161 : integer, intent(in) :: &
162 : hydromet_idx ! Index of a hydrometeor in the hydromet array.
163 :
164 : type (hm_metadata_type), intent(in) :: &
165 : hm_metadata
166 :
167 : ! Return Variable
168 : integer :: &
169 : pdf_idx ! Index of a hydrometeor in the PDF array.
170 :
171 :
172 : ! Initialize pdf_idx.
173 0 : pdf_idx = 0
174 :
175 0 : if ( hydromet_idx == hm_metadata%iirr ) then
176 :
177 : ! Index for rain water mixing ratio, rr.
178 0 : pdf_idx = hm_metadata%iiPDF_rr
179 :
180 0 : elseif ( hydromet_idx == hm_metadata%iiNr ) then
181 :
182 : ! Index for rain drop concentration, Nr.
183 0 : pdf_idx = hm_metadata%iiPDF_Nr
184 :
185 0 : elseif ( hydromet_idx == hm_metadata%iiri ) then
186 :
187 : ! Index for ice mixing ratio, ri.
188 0 : pdf_idx = hm_metadata%iiPDF_ri
189 :
190 0 : elseif ( hydromet_idx == hm_metadata%iiNi ) then
191 :
192 : ! Index for ice concentration, Ni.
193 0 : pdf_idx = hm_metadata%iiPDF_Ni
194 :
195 0 : elseif ( hydromet_idx == hm_metadata%iirs ) then
196 :
197 : ! Index for snow mixing ratio, rs.
198 0 : pdf_idx = hm_metadata%iiPDF_rs
199 :
200 0 : elseif ( hydromet_idx == hm_metadata%iiNs ) then
201 :
202 : ! Index for snow flake concentration, Ns.
203 0 : pdf_idx = hm_metadata%iiPDF_Ns
204 :
205 0 : elseif ( hydromet_idx == hm_metadata%iirg ) then
206 :
207 : ! Index for graupel mixing ratio, rg.
208 0 : pdf_idx = hm_metadata%iiPDF_rg
209 :
210 0 : elseif ( hydromet_idx == hm_metadata%iiNg ) then
211 :
212 : ! Index for graupel concentration, Ng.
213 0 : pdf_idx = hm_metadata%iiPDF_Ng
214 :
215 : endif
216 :
217 :
218 : return
219 :
220 : end function hydromet2pdf_idx
221 :
222 : !=============================================================================
223 0 : function rx2Nx_hm_idx( rx_idx, hm_metadata ) result( Nx_idx )
224 :
225 : ! Description:
226 : ! Returns the position in the hydrometeor array of the specific
227 : ! precipitating hydrometeor concentration (Nx_idx) corresponding to the
228 : ! precipitating hydrometeor mixing ratio (rx_idx) of the same species of
229 : ! precipitating hydrometeor (rain, ice, snow, or graupel).
230 :
231 : ! References:
232 : !-----------------------------------------------------------------------
233 :
234 : use corr_varnce_module, only: &
235 : hm_metadata_type
236 :
237 : implicit none
238 :
239 : ! Input Variable
240 : integer, intent(in) :: &
241 : rx_idx ! Index of the mixing ratio in the hydrometeor array.
242 :
243 : type (hm_metadata_type), intent(in) :: &
244 : hm_metadata
245 :
246 : ! Return Variable
247 : integer :: &
248 : Nx_idx ! Index of the concentration in the hydrometeor array.
249 :
250 :
251 : ! Initialize Nx_idx.
252 0 : Nx_idx = 0
253 :
254 0 : if ( rx_idx == hm_metadata%iirr ) then
255 :
256 : ! Index for rain drop concentration, Nr.
257 0 : Nx_idx = hm_metadata%iiNr
258 :
259 0 : elseif ( rx_idx == hm_metadata%iiri ) then
260 :
261 : ! Index for ice crystal concentration, Ni.
262 0 : Nx_idx = hm_metadata%iiNi
263 :
264 0 : elseif ( rx_idx == hm_metadata%iirs ) then
265 :
266 : ! Index for snow flake concentration, Ns.
267 0 : Nx_idx = hm_metadata%iiNs
268 :
269 0 : elseif ( rx_idx == hm_metadata%iirg ) then
270 :
271 : ! Index for graupel concentration, Ng.
272 0 : Nx_idx = hm_metadata%iiNg
273 :
274 : endif
275 :
276 : return
277 :
278 : end function rx2Nx_hm_idx
279 :
280 : !=============================================================================
281 0 : function Nx2rx_hm_idx( Nx_idx, hm_metadata ) result( rx_idx )
282 :
283 : ! Description:
284 : ! Returns the position in the hydrometeor array of the specific
285 : ! precipitating hydrometeor mixing ratio (rx_idx) corresponding to the
286 : ! precipitating hydrometeor concentration (Nx_idx) of the same species of
287 : ! precipitating hydrometeor (rain, ice, snow, or graupel).
288 :
289 : ! References:
290 : !-----------------------------------------------------------------------
291 :
292 : use corr_varnce_module, only: &
293 : hm_metadata_type
294 :
295 : implicit none
296 :
297 : ! Input Variable
298 : integer, intent(in) :: &
299 : Nx_idx ! Index of the concentration in the hydrometeor array.
300 :
301 : type (hm_metadata_type), intent(in) :: &
302 : hm_metadata
303 :
304 : ! Return Variable
305 : integer :: &
306 : rx_idx ! Index of the mixing ratio in the hydrometeor array.
307 :
308 :
309 : ! Initialize rx_idx.
310 0 : rx_idx = 0
311 :
312 0 : if ( Nx_idx == hm_metadata%iiNr ) then
313 :
314 : ! Index for rain water mixing ratio, rr.
315 0 : rx_idx = hm_metadata%iirr
316 :
317 0 : elseif ( Nx_idx == hm_metadata%iiNi ) then
318 :
319 : ! Index for ice mixing ratio, ri.
320 0 : rx_idx = hm_metadata%iiri
321 :
322 0 : elseif ( Nx_idx == hm_metadata%iiNs ) then
323 :
324 : ! Index for snow mixing ratio, rs.
325 0 : rx_idx = hm_metadata%iirs
326 :
327 0 : elseif ( Nx_idx == hm_metadata%iiNg ) then
328 :
329 : ! Index for graupel mixing ratio, rg.
330 0 : rx_idx = hm_metadata%iirg
331 :
332 : endif
333 :
334 :
335 : return
336 :
337 : end function Nx2rx_hm_idx
338 :
339 : !=============================================================================
340 0 : function mvr_hm_max( hydromet_idx, hm_metadata ) result( mvr_hydromet_max )
341 :
342 : ! Description:
343 : ! Returns the maximum allowable mean volume radius of a specific
344 : ! precipitating hydrometeor type (rain, ice, snow, or graupel) corresponding
345 : ! to the precipitating hydrometeor index, whether that index is for the
346 : ! mixing ratio or concentration associated with that hydrometeor type.
347 :
348 : ! References:
349 : !-----------------------------------------------------------------------
350 :
351 : use corr_varnce_module, only: &
352 : hm_metadata_type
353 :
354 : use constants_clubb, only: &
355 : mvr_rain_max, & ! Constant(s)
356 : mvr_ice_max, &
357 : mvr_snow_max, &
358 : mvr_graupel_max, &
359 : zero
360 :
361 : use clubb_precision, only: &
362 : core_rknd ! Variable(s)
363 :
364 : implicit none
365 :
366 : ! Input Variable
367 : integer, intent(in) :: &
368 : hydromet_idx ! Index of a hydrometeor in the hydromet array.
369 :
370 : type (hm_metadata_type), intent(in) :: &
371 : hm_metadata
372 :
373 :
374 : ! Return Variable
375 : real( kind = core_rknd ) :: &
376 : mvr_hydromet_max ! Maximum allowable mean volume radius [m]
377 :
378 :
379 : ! Initialize mvr_hydromet_max.
380 0 : mvr_hydromet_max = zero
381 :
382 0 : if ( hydromet_idx == hm_metadata%iirr .or. hydromet_idx == hm_metadata%iiNr ) then
383 :
384 : ! Maximum allowable mean volume radius for rain drops.
385 : mvr_hydromet_max = mvr_rain_max
386 :
387 0 : elseif ( hydromet_idx == hm_metadata%iiri .or. hydromet_idx == hm_metadata%iiNi ) then
388 :
389 : ! Maximum allowable mean volume radius for ice crystals.
390 : mvr_hydromet_max = mvr_ice_max
391 :
392 0 : elseif ( hydromet_idx == hm_metadata%iirs .or. hydromet_idx == hm_metadata%iiNs ) then
393 :
394 : ! Maximum allowable mean volume radius for snow flakes.
395 : mvr_hydromet_max = mvr_snow_max
396 :
397 0 : elseif ( hydromet_idx == hm_metadata%iirg .or. hydromet_idx == hm_metadata%iiNg ) then
398 :
399 : ! Maximum allowable mean volume radius for graupel.
400 0 : mvr_hydromet_max = mvr_graupel_max
401 :
402 : endif
403 :
404 :
405 : return
406 :
407 : end function mvr_hm_max
408 :
409 : !===============================================================================
410 :
411 : end module index_mapping
|