@@ -7,19 +7,6 @@ module ic_us_standard_atmosphere
7
7
!
8
8
!- ------------------------------------------------------------------------------
9
9
10
- use shr_kind_mod, only: r8 = > shr_kind_r8
11
- use spmd_utils, only: masterproc
12
-
13
- use hycoef, only: ps0, hyam, hybm
14
- use physconst, only: gravit
15
- ! use constituents, only: cnst_name
16
- ! use const_init, only: cnst_init_default
17
-
18
- use std_atm_profile, only: std_atm_pres, std_atm_height, std_atm_temp
19
-
20
- use cam_logfile, only: iulog
21
- use cam_abortutils, only: endrun, check_allocate
22
-
23
10
implicit none
24
11
private
25
12
save
@@ -33,6 +20,19 @@ module ic_us_standard_atmosphere
33
20
subroutine us_std_atm_set_ic (latvals , lonvals , zint , U , V , T , PS , PHIS_IN , &
34
21
PHIS_OUT , Q , m_cnst , mask , verbose )
35
22
23
+ use shr_kind_mod, only: r8 = > shr_kind_r8 , cx = > shr_kind_cx
24
+ use ccpp_kinds, only: kind_phys
25
+ use spmd_utils, only: masterproc
26
+ use hycoef, only: ps0, hyam, hybm
27
+ use physconst, only: gravit
28
+ use std_atm_profile, only: std_atm_pres, std_atm_height, std_atm_temp
29
+ use cam_logfile, only: iulog
30
+ use cam_abortutils, only: endrun, check_allocate
31
+ use runtime_obj, only: wv_stdname
32
+ use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
33
+ use cam_ccpp_cap, only: cam_model_const_properties
34
+ use cam_constituents, only: const_get_index, const_qmin
35
+
36
36
!- ---------------------------------------------------------------------------
37
37
!
38
38
! Set initial values for static atmosphere with vertical profile from US
@@ -58,14 +58,22 @@ subroutine us_std_atm_set_ic(latvals, lonvals, zint, U, V, T, PS, PHIS_IN, &
58
58
! Local variables
59
59
logical , allocatable :: mask_use(:)
60
60
logical :: verbose_use
61
+ logical :: const_has_default
61
62
integer :: i, k, m
62
63
integer :: ncol
63
64
integer :: nlev, nlevp
64
65
integer :: ncnst
65
66
integer :: iret
67
+ integer :: ix_q, m_cnst_ix_q
66
68
character (len=* ), parameter :: subname = ' us_std_atm_set_ic'
69
+ character (len= cx) :: errmsg ! CCPP error message
67
70
real (r8 ) :: psurf(1 )
68
71
real (r8 ), allocatable :: pmid(:), zmid(:), zmid2d(:,:)
72
+ real (kind_phys) :: const_default_value ! Constituent default value
73
+ real (kind_phys) :: const_qmin_value ! Constituent minimum value
74
+
75
+ ! Private array of constituent properties (for property interface functions)
76
+ type (ccpp_constituent_prop_ptr_t), pointer :: const_props(:)
69
77
!- ---------------------------------------------------------------------------
70
78
71
79
! check input consistency
@@ -208,35 +216,58 @@ subroutine us_std_atm_set_ic(latvals, lonvals, zint, U, V, T, PS, PHIS_IN, &
208
216
zmid2d = 0.5_r8 * (zint(:,1 :nlev) + zint(:,2 :nlev+1 ))
209
217
end if
210
218
211
- ncnst = size (m_cnst, 1 )
219
+ ! Get water vapor constituent index:
220
+ call const_get_index(wv_stdname, ix_q)
221
+
222
+ ! Determine which "Q" variable index matches water vapor:
223
+ m_cnst_ix_q = findloc(m_cnst, ix_q, dim= 1 )
224
+
225
+ ncnst = size (m_cnst)
212
226
do m = 1 , ncnst
213
- if (m_cnst(m) == 1 ) then
227
+ if (m_cnst(m) == m_cnst_ix_q ) then
214
228
! No water vapor in profile
215
229
do k = 1 , nlev
216
230
where (mask_use)
217
231
Q(:,k,m_cnst(m)) = 0.0_r8
218
232
end where
219
233
end do
220
- ! Un-comment once constituents are working in CAMDEN -JN:
221
- #if 0
222
234
if (masterproc .and. verbose_use) then
223
- write(iulog,*) ' ', trim(cnst_name(m_cnst(m))), ' initialized by '//subname
224
- end if
225
- else
226
- if (present(zint)) then
227
- call cnst_init_default(m_cnst(m), latvals, lonvals, Q(:,:,m_cnst(m)),&
228
- mask=mask_use, verbose=verbose_use, notfound=.false., z=zmid2d)
229
- else
230
- call cnst_init_default(m_cnst(m), latvals, lonvals, Q(:,:,m_cnst(m)),&
231
- mask=mask_use, verbose=verbose_use, notfound=.false.)
235
+ write (iulog,* ) ' ' , wv_stdname, ' initialized by ' // subname
232
236
end if
233
- #else
234
237
else
235
- ! Initialize cloud liquid and rain until constituent routines are enabled:
236
- Q(:,:,m_cnst(m)) = 0.0_r8
237
- #endif
238
- end if
239
- end do
238
+
239
+ ! Extract constituent minimum value:
240
+ const_qmin_value = const_qmin(m_cnst(m))
241
+
242
+ ! Initialize constituent to its minimum value:
243
+ Q(:,:,m) = real (const_qmin_value, r8 )
244
+
245
+ if (iret /= 0 ) then
246
+ call endrun(errmsg, file= __FILE__, line= __LINE__)
247
+ end if
248
+
249
+ if (const_has_default) then
250
+
251
+ ! If default value exists, then extract default value
252
+ ! from constituent properties object:
253
+ call const_props(m_cnst(m))% default_value(const_default_value, &
254
+ iret, &
255
+ errmsg)
256
+ if (iret /= 0 ) then
257
+ call endrun(errmsg, file= __FILE__, line= __LINE__)
258
+ end if
259
+
260
+ ! Set constituent to default value in masked region:
261
+ do k= 1 ,nlev
262
+ where (mask_use)
263
+ Q(:,k,m) = real (const_default_value, r8 )
264
+ end where
265
+ end do
266
+
267
+ end if ! has_default
268
+
269
+ end if ! water vapor
270
+ end do ! ncnst
240
271
241
272
if (allocated (zmid2d)) deallocate (zmid2d)
242
273
0 commit comments