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 : ! Hydrometeor array indices
56 : use array_index, only: &
57 : iirr, & ! Hydrometeor array index for rain water mixing ratio, rr
58 : iirs, & ! Hydrometeor array index for snow mixing ratio, rs
59 : iiri, & ! Hydrometeor array index for ice mixing ratio, ri
60 : iirg, & ! Hydrometeor array index for graupel mixing ratio, rg
61 : iiNr, & ! Hydrometeor array index for rain drop concentration, Nr
62 : iiNs, & ! Hydrometeor array index for snow concentration, Ns
63 : iiNi, & ! Hydrometeor array index for ice concentration, Ni
64 : iiNg, & ! Hydrometeor array index for graupel concentration, Ng
65 : ! PDF array indices
66 : iiPDF_rr, & ! PDF array index for rain water mixing ratio, rr
67 : iiPDF_rs, & ! PDF array index for snow mixing ratio, rs
68 : iiPDF_ri, & ! PDF array index for ice mixing ratio, ri
69 : iiPDF_rg, & ! PDF array index for graupel mixing ratio, rg
70 : iiPDF_Nr, & ! PDF array index for rain drop concentration, Nr
71 : iiPDF_Ns, & ! PDF array index for snow concentration, Ns
72 : iiPDF_Ni, & ! PDF array index for ice concentration, Ni
73 : iiPDF_Ng ! PDF array index for graupel concentration, Ng
74 :
75 : implicit none
76 :
77 : private ! Default Scope
78 :
79 : public :: pdf2hydromet_idx, &
80 : hydromet2pdf_idx, &
81 : rx2Nx_hm_idx, &
82 : Nx2rx_hm_idx, &
83 : mvr_hm_max
84 :
85 : contains
86 :
87 : !=============================================================================
88 0 : function pdf2hydromet_idx( pdf_idx ) result( hydromet_idx )
89 :
90 : ! Description:
91 : ! Returns the position of a specific precipitating hydrometeor corresponding
92 : ! to the PDF index (pdf_idx) in the precipitating hydrometeor array
93 : ! (hydromet_idx).
94 :
95 : ! References:
96 : !-----------------------------------------------------------------------
97 :
98 : implicit none
99 :
100 : ! Input Variables
101 : integer, intent(in) :: &
102 : pdf_idx ! Index of a hydrometeor in the PDF array.
103 :
104 : ! Return Variable
105 : integer :: &
106 : hydromet_idx ! Index of a hydrometeor in the hydromet array.
107 :
108 :
109 : ! Initialize hydromet_idx
110 0 : hydromet_idx = 0
111 :
112 0 : if ( pdf_idx == iiPDF_rr ) then
113 :
114 : ! Index for rain water mixing ratio, rr.
115 0 : hydromet_idx = iirr
116 :
117 0 : elseif ( pdf_idx == iiPDF_Nr ) then
118 :
119 : ! Index for rain drop concentration, Nr.
120 0 : hydromet_idx = iiNr
121 :
122 0 : elseif ( pdf_idx == iiPDF_rs ) then
123 :
124 : ! Index for snow mixing ratio, rs.
125 0 : hydromet_idx = iirs
126 :
127 0 : elseif ( pdf_idx == iiPDF_Ns ) then
128 :
129 : ! Index for snow flake concentration, Ns.
130 0 : hydromet_idx = iiNs
131 :
132 0 : elseif ( pdf_idx == iiPDF_rg ) then
133 :
134 : ! Index for graupel mixing ratio, rg.
135 0 : hydromet_idx = iirg
136 :
137 0 : elseif ( pdf_idx == iiPDF_Ng ) then
138 :
139 : ! Index for graupel concentration, Ng.
140 0 : hydromet_idx = iiNg
141 :
142 0 : elseif ( pdf_idx == iiPDF_ri ) then
143 :
144 : ! Index for ice mixing ratio, ri.
145 0 : hydromet_idx = iiri
146 :
147 0 : elseif ( pdf_idx == iiPDF_Ni ) then
148 :
149 : ! Index for ice concentration, Ni.
150 0 : hydromet_idx = iiNi
151 :
152 : endif
153 :
154 :
155 : return
156 :
157 : end function pdf2hydromet_idx
158 :
159 : !=============================================================================
160 0 : function hydromet2pdf_idx( hydromet_idx ) result( pdf_idx )
161 :
162 : ! Description:
163 : ! Returns the position of a specific precipitating hydrometeor corresponding
164 : ! to the precipitating hydrometeor index (hydromet_idx) in the PDF array
165 : ! (pdf_idx).
166 :
167 : ! References:
168 : !-----------------------------------------------------------------------
169 :
170 : implicit none
171 :
172 : ! Input Variable
173 : integer, intent(in) :: &
174 : hydromet_idx ! Index of a hydrometeor in the hydromet array.
175 :
176 : ! Return Variable
177 : integer :: &
178 : pdf_idx ! Index of a hydrometeor in the PDF array.
179 :
180 :
181 : ! Initialize pdf_idx.
182 0 : pdf_idx = 0
183 :
184 0 : if ( hydromet_idx == iirr ) then
185 :
186 : ! Index for rain water mixing ratio, rr.
187 0 : pdf_idx = iiPDF_rr
188 :
189 0 : elseif ( hydromet_idx == iiNr ) then
190 :
191 : ! Index for rain drop concentration, Nr.
192 0 : pdf_idx = iiPDF_Nr
193 :
194 0 : elseif ( hydromet_idx == iiri ) then
195 :
196 : ! Index for ice mixing ratio, ri.
197 0 : pdf_idx = iiPDF_ri
198 :
199 0 : elseif ( hydromet_idx == iiNi ) then
200 :
201 : ! Index for ice concentration, Ni.
202 0 : pdf_idx = iiPDF_Ni
203 :
204 0 : elseif ( hydromet_idx == iirs ) then
205 :
206 : ! Index for snow mixing ratio, rs.
207 0 : pdf_idx = iiPDF_rs
208 :
209 0 : elseif ( hydromet_idx == iiNs ) then
210 :
211 : ! Index for snow flake concentration, Ns.
212 0 : pdf_idx = iiPDF_Ns
213 :
214 0 : elseif ( hydromet_idx == iirg ) then
215 :
216 : ! Index for graupel mixing ratio, rg.
217 0 : pdf_idx = iiPDF_rg
218 :
219 0 : elseif ( hydromet_idx == iiNg ) then
220 :
221 : ! Index for graupel concentration, Ng.
222 0 : pdf_idx = iiPDF_Ng
223 :
224 : endif
225 :
226 :
227 : return
228 :
229 : end function hydromet2pdf_idx
230 :
231 : !=============================================================================
232 0 : function rx2Nx_hm_idx( rx_idx ) result( Nx_idx )
233 :
234 : ! Description:
235 : ! Returns the position in the hydrometeor array of the specific
236 : ! precipitating hydrometeor concentration (Nx_idx) corresponding to the
237 : ! precipitating hydrometeor mixing ratio (rx_idx) of the same species of
238 : ! precipitating hydrometeor (rain, ice, snow, or graupel).
239 :
240 : ! References:
241 : !-----------------------------------------------------------------------
242 :
243 : implicit none
244 :
245 : ! Input Variable
246 : integer, intent(in) :: &
247 : rx_idx ! Index of the mixing ratio in the hydrometeor array.
248 :
249 : ! Return Variable
250 : integer :: &
251 : Nx_idx ! Index of the concentration in the hydrometeor array.
252 :
253 :
254 : ! Initialize Nx_idx.
255 0 : Nx_idx = 0
256 :
257 0 : if ( rx_idx == iirr ) then
258 :
259 : ! Index for rain drop concentration, Nr.
260 0 : Nx_idx = iiNr
261 :
262 0 : elseif ( rx_idx == iiri ) then
263 :
264 : ! Index for ice crystal concentration, Ni.
265 0 : Nx_idx = iiNi
266 :
267 0 : elseif ( rx_idx == iirs ) then
268 :
269 : ! Index for snow flake concentration, Ns.
270 0 : Nx_idx = iiNs
271 :
272 0 : elseif ( rx_idx == iirg ) then
273 :
274 : ! Index for graupel concentration, Ng.
275 0 : Nx_idx = iiNg
276 :
277 : endif
278 :
279 :
280 : return
281 :
282 : end function rx2Nx_hm_idx
283 :
284 : !=============================================================================
285 0 : function Nx2rx_hm_idx( Nx_idx ) result( rx_idx )
286 :
287 : ! Description:
288 : ! Returns the position in the hydrometeor array of the specific
289 : ! precipitating hydrometeor mixing ratio (rx_idx) corresponding to the
290 : ! precipitating hydrometeor concentration (Nx_idx) of the same species of
291 : ! precipitating hydrometeor (rain, ice, snow, or graupel).
292 :
293 : ! References:
294 : !-----------------------------------------------------------------------
295 :
296 : implicit none
297 :
298 : ! Input Variable
299 : integer, intent(in) :: &
300 : Nx_idx ! Index of the concentration in the hydrometeor array.
301 :
302 : ! Return Variable
303 : integer :: &
304 : rx_idx ! Index of the mixing ratio in the hydrometeor array.
305 :
306 :
307 : ! Initialize rx_idx.
308 0 : rx_idx = 0
309 :
310 0 : if ( Nx_idx == iiNr ) then
311 :
312 : ! Index for rain water mixing ratio, rr.
313 0 : rx_idx = iirr
314 :
315 0 : elseif ( Nx_idx == iiNi ) then
316 :
317 : ! Index for ice mixing ratio, ri.
318 0 : rx_idx = iiri
319 :
320 0 : elseif ( Nx_idx == iiNs ) then
321 :
322 : ! Index for snow mixing ratio, rs.
323 0 : rx_idx = iirs
324 :
325 0 : elseif ( Nx_idx == iiNg ) then
326 :
327 : ! Index for graupel mixing ratio, rg.
328 0 : rx_idx = iirg
329 :
330 : endif
331 :
332 :
333 : return
334 :
335 : end function Nx2rx_hm_idx
336 :
337 : !=============================================================================
338 0 : function mvr_hm_max( hydromet_idx ) result( mvr_hydromet_max )
339 :
340 : ! Description:
341 : ! Returns the maximum allowable mean volume radius of a specific
342 : ! precipitating hydrometeor type (rain, ice, snow, or graupel) corresponding
343 : ! to the precipitating hydrometeor index, whether that index is for the
344 : ! mixing ratio or concentration associated with that hydrometeor type.
345 :
346 : ! References:
347 : !-----------------------------------------------------------------------
348 :
349 : use constants_clubb, only: &
350 : mvr_rain_max, & ! Constant(s)
351 : mvr_ice_max, &
352 : mvr_snow_max, &
353 : mvr_graupel_max, &
354 : zero
355 :
356 : use clubb_precision, only: &
357 : core_rknd ! Variable(s)
358 :
359 : implicit none
360 :
361 : ! Input Variable
362 : integer, intent(in) :: &
363 : hydromet_idx ! Index of a hydrometeor in the hydromet array.
364 :
365 : ! Return Variable
366 : real( kind = core_rknd ) :: &
367 : mvr_hydromet_max ! Maximum allowable mean volume radius [m]
368 :
369 :
370 : ! Initialize mvr_hydromet_max.
371 0 : mvr_hydromet_max = zero
372 :
373 0 : if ( hydromet_idx == iirr .or. hydromet_idx == iiNr ) then
374 :
375 : ! Maximum allowable mean volume radius for rain drops.
376 : mvr_hydromet_max = mvr_rain_max
377 :
378 0 : elseif ( hydromet_idx == iiri .or. hydromet_idx == iiNi ) then
379 :
380 : ! Maximum allowable mean volume radius for ice crystals.
381 : mvr_hydromet_max = mvr_ice_max
382 :
383 0 : elseif ( hydromet_idx == iirs .or. hydromet_idx == iiNs ) then
384 :
385 : ! Maximum allowable mean volume radius for snow flakes.
386 : mvr_hydromet_max = mvr_snow_max
387 :
388 0 : elseif ( hydromet_idx == iirg .or. hydromet_idx == iiNg ) then
389 :
390 : ! Maximum allowable mean volume radius for graupel.
391 0 : mvr_hydromet_max = mvr_graupel_max
392 :
393 : endif
394 :
395 :
396 : return
397 :
398 : end function mvr_hm_max
399 :
400 : !===============================================================================
401 :
402 : end module index_mapping
|