forked from ESCOMP/CLUBB_CESM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_mapping.F90
402 lines (275 loc) · 10.8 KB
/
index_mapping.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
!---------------------------------------------------------------------------
! $Id$
!===============================================================================
module index_mapping
! Description:
! Functions to map back and forth between the PDF arrays and the hydrometeor
! arrays.
! The “iiPDF” indices are used to index all PDF variates, including all
! hydrometeor variates.
! The “ii” indices are used to index hydrometeor arrays.
! The “ii” variates are a subset of the “iiPDF” variates.
! Conversions between the two sets of indices are done by the
! functions pdf2hydromet_idx and hydromet2pdf_idx below.
!
! ------------------------------------------------------------------------
!
! iiPDF indices:
!
! Included indices:
! iiPDF_chi, iiPDF_eta, iiPDF_w, iiPDF_Ncn, iiPDF_rr, & all other hydrometeors
!
! Number of indices: pdf_dim
!
! Examples of arrays dimensioned by pdf_dim:
! mu_x_1_n, corr_array_n_cloud, . . .
!
! Declared as module variables in module array_index
!
! Initialized in subroutine setup_pdf_indices
!
! ----------------------------------------------------------------------
!
! ii indices:
!
! Included indices:
! iirr, iiNr, iiri, iiNi, iirs, iiNs, iirg, iiNg
!
! Number of indices: hydromet_dim
!
! Examples of arrays dimensioned by hydromet_dim:
! hydromet, wphydrometp, . . .
!
! Declared as module variables in module array_index.
!
! Initialized in subroutine init_microphys
!
! -----------------------------------------------------------------------
!
! References:
! None
!-------------------------------------------------------------------------
! Hydrometeor array indices
use array_index, only: &
iirr, & ! Hydrometeor array index for rain water mixing ratio, rr
iirs, & ! Hydrometeor array index for snow mixing ratio, rs
iiri, & ! Hydrometeor array index for ice mixing ratio, ri
iirg, & ! Hydrometeor array index for graupel mixing ratio, rg
iiNr, & ! Hydrometeor array index for rain drop concentration, Nr
iiNs, & ! Hydrometeor array index for snow concentration, Ns
iiNi, & ! Hydrometeor array index for ice concentration, Ni
iiNg, & ! Hydrometeor array index for graupel concentration, Ng
! PDF array indices
iiPDF_rr, & ! PDF array index for rain water mixing ratio, rr
iiPDF_rs, & ! PDF array index for snow mixing ratio, rs
iiPDF_ri, & ! PDF array index for ice mixing ratio, ri
iiPDF_rg, & ! PDF array index for graupel mixing ratio, rg
iiPDF_Nr, & ! PDF array index for rain drop concentration, Nr
iiPDF_Ns, & ! PDF array index for snow concentration, Ns
iiPDF_Ni, & ! PDF array index for ice concentration, Ni
iiPDF_Ng ! PDF array index for graupel concentration, Ng
implicit none
private ! Default Scope
public :: pdf2hydromet_idx, &
hydromet2pdf_idx, &
rx2Nx_hm_idx, &
Nx2rx_hm_idx, &
mvr_hm_max
contains
!=============================================================================
function pdf2hydromet_idx( pdf_idx ) result( hydromet_idx )
! Description:
! Returns the position of a specific precipitating hydrometeor corresponding
! to the PDF index (pdf_idx) in the precipitating hydrometeor array
! (hydromet_idx).
! References:
!-----------------------------------------------------------------------
implicit none
! Input Variables
integer, intent(in) :: &
pdf_idx ! Index of a hydrometeor in the PDF array.
! Return Variable
integer :: &
hydromet_idx ! Index of a hydrometeor in the hydromet array.
! Initialize hydromet_idx
hydromet_idx = 0
if ( pdf_idx == iiPDF_rr ) then
! Index for rain water mixing ratio, rr.
hydromet_idx = iirr
elseif ( pdf_idx == iiPDF_Nr ) then
! Index for rain drop concentration, Nr.
hydromet_idx = iiNr
elseif ( pdf_idx == iiPDF_rs ) then
! Index for snow mixing ratio, rs.
hydromet_idx = iirs
elseif ( pdf_idx == iiPDF_Ns ) then
! Index for snow flake concentration, Ns.
hydromet_idx = iiNs
elseif ( pdf_idx == iiPDF_rg ) then
! Index for graupel mixing ratio, rg.
hydromet_idx = iirg
elseif ( pdf_idx == iiPDF_Ng ) then
! Index for graupel concentration, Ng.
hydromet_idx = iiNg
elseif ( pdf_idx == iiPDF_ri ) then
! Index for ice mixing ratio, ri.
hydromet_idx = iiri
elseif ( pdf_idx == iiPDF_Ni ) then
! Index for ice concentration, Ni.
hydromet_idx = iiNi
endif
return
end function pdf2hydromet_idx
!=============================================================================
function hydromet2pdf_idx( hydromet_idx ) result( pdf_idx )
! Description:
! Returns the position of a specific precipitating hydrometeor corresponding
! to the precipitating hydrometeor index (hydromet_idx) in the PDF array
! (pdf_idx).
! References:
!-----------------------------------------------------------------------
implicit none
! Input Variable
integer, intent(in) :: &
hydromet_idx ! Index of a hydrometeor in the hydromet array.
! Return Variable
integer :: &
pdf_idx ! Index of a hydrometeor in the PDF array.
! Initialize pdf_idx.
pdf_idx = 0
if ( hydromet_idx == iirr ) then
! Index for rain water mixing ratio, rr.
pdf_idx = iiPDF_rr
elseif ( hydromet_idx == iiNr ) then
! Index for rain drop concentration, Nr.
pdf_idx = iiPDF_Nr
elseif ( hydromet_idx == iiri ) then
! Index for ice mixing ratio, ri.
pdf_idx = iiPDF_ri
elseif ( hydromet_idx == iiNi ) then
! Index for ice concentration, Ni.
pdf_idx = iiPDF_Ni
elseif ( hydromet_idx == iirs ) then
! Index for snow mixing ratio, rs.
pdf_idx = iiPDF_rs
elseif ( hydromet_idx == iiNs ) then
! Index for snow flake concentration, Ns.
pdf_idx = iiPDF_Ns
elseif ( hydromet_idx == iirg ) then
! Index for graupel mixing ratio, rg.
pdf_idx = iiPDF_rg
elseif ( hydromet_idx == iiNg ) then
! Index for graupel concentration, Ng.
pdf_idx = iiPDF_Ng
endif
return
end function hydromet2pdf_idx
!=============================================================================
function rx2Nx_hm_idx( rx_idx ) result( Nx_idx )
! Description:
! Returns the position in the hydrometeor array of the specific
! precipitating hydrometeor concentration (Nx_idx) corresponding to the
! precipitating hydrometeor mixing ratio (rx_idx) of the same species of
! precipitating hydrometeor (rain, ice, snow, or graupel).
! References:
!-----------------------------------------------------------------------
implicit none
! Input Variable
integer, intent(in) :: &
rx_idx ! Index of the mixing ratio in the hydrometeor array.
! Return Variable
integer :: &
Nx_idx ! Index of the concentration in the hydrometeor array.
! Initialize Nx_idx.
Nx_idx = 0
if ( rx_idx == iirr ) then
! Index for rain drop concentration, Nr.
Nx_idx = iiNr
elseif ( rx_idx == iiri ) then
! Index for ice crystal concentration, Ni.
Nx_idx = iiNi
elseif ( rx_idx == iirs ) then
! Index for snow flake concentration, Ns.
Nx_idx = iiNs
elseif ( rx_idx == iirg ) then
! Index for graupel concentration, Ng.
Nx_idx = iiNg
endif
return
end function rx2Nx_hm_idx
!=============================================================================
function Nx2rx_hm_idx( Nx_idx ) result( rx_idx )
! Description:
! Returns the position in the hydrometeor array of the specific
! precipitating hydrometeor mixing ratio (rx_idx) corresponding to the
! precipitating hydrometeor concentration (Nx_idx) of the same species of
! precipitating hydrometeor (rain, ice, snow, or graupel).
! References:
!-----------------------------------------------------------------------
implicit none
! Input Variable
integer, intent(in) :: &
Nx_idx ! Index of the concentration in the hydrometeor array.
! Return Variable
integer :: &
rx_idx ! Index of the mixing ratio in the hydrometeor array.
! Initialize rx_idx.
rx_idx = 0
if ( Nx_idx == iiNr ) then
! Index for rain water mixing ratio, rr.
rx_idx = iirr
elseif ( Nx_idx == iiNi ) then
! Index for ice mixing ratio, ri.
rx_idx = iiri
elseif ( Nx_idx == iiNs ) then
! Index for snow mixing ratio, rs.
rx_idx = iirs
elseif ( Nx_idx == iiNg ) then
! Index for graupel mixing ratio, rg.
rx_idx = iirg
endif
return
end function Nx2rx_hm_idx
!=============================================================================
function mvr_hm_max( hydromet_idx ) result( mvr_hydromet_max )
! Description:
! Returns the maximum allowable mean volume radius of a specific
! precipitating hydrometeor type (rain, ice, snow, or graupel) corresponding
! to the precipitating hydrometeor index, whether that index is for the
! mixing ratio or concentration associated with that hydrometeor type.
! References:
!-----------------------------------------------------------------------
use constants_clubb, only: &
mvr_rain_max, & ! Constant(s)
mvr_ice_max, &
mvr_snow_max, &
mvr_graupel_max, &
zero
use clubb_precision, only: &
core_rknd ! Variable(s)
implicit none
! Input Variable
integer, intent(in) :: &
hydromet_idx ! Index of a hydrometeor in the hydromet array.
! Return Variable
real( kind = core_rknd ) :: &
mvr_hydromet_max ! Maximum allowable mean volume radius [m]
! Initialize mvr_hydromet_max.
mvr_hydromet_max = zero
if ( hydromet_idx == iirr .or. hydromet_idx == iiNr ) then
! Maximum allowable mean volume radius for rain drops.
mvr_hydromet_max = mvr_rain_max
elseif ( hydromet_idx == iiri .or. hydromet_idx == iiNi ) then
! Maximum allowable mean volume radius for ice crystals.
mvr_hydromet_max = mvr_ice_max
elseif ( hydromet_idx == iirs .or. hydromet_idx == iiNs ) then
! Maximum allowable mean volume radius for snow flakes.
mvr_hydromet_max = mvr_snow_max
elseif ( hydromet_idx == iirg .or. hydromet_idx == iiNg ) then
! Maximum allowable mean volume radius for graupel.
mvr_hydromet_max = mvr_graupel_max
endif
return
end function mvr_hm_max
!===============================================================================
end module index_mapping