Line data Source code
1 : ! This module is the CAM version of the CCPP generated module of the same name
2 : module ccpp_constituent_prop_mod
3 :
4 : implicit none
5 : private
6 :
7 : ! Define CAM version of constituent properties mod
8 : type, public :: ccpp_constituent_prop_ptr_t
9 : logical, private :: thermo_active = .false.
10 : logical, private :: water_species = .false.
11 : logical, private :: species_is_dry
12 : character(len=256) :: std_name = ''
13 :
14 : contains
15 : procedure :: standard_name => ccp_get_standard_name
16 : procedure :: set_standard_name => ccp_set_standard_name
17 : procedure :: is_thermo_active => ccp_is_thermo_active
18 : procedure :: is_water_species => ccp_is_water_species
19 : procedure :: set_thermo_active => ccp_set_thermo_active
20 : procedure :: set_water_species => ccp_set_water_species
21 : procedure :: is_dry => ccp_is_dry
22 : procedure :: set_dry => ccp_set_dry
23 :
24 : end type ccpp_constituent_prop_ptr_t
25 :
26 : ! CCPP properties init routine
27 : public :: ccpp_const_props_init
28 :
29 : ! Public properties DDT variable:
30 : type(ccpp_constituent_prop_ptr_t), allocatable, public :: ccpp_const_props(:)
31 :
32 : contains
33 :
34 : !+++++++++++++++++++++++++++++++++++++++
35 : !CCPP constituent properties DDT methods
36 : !+++++++++++++++++++++++++++++++++++++++
37 :
38 5077440 : subroutine ccp_get_standard_name(this, std_name, errcode, errmsg)
39 : ! Return this constituent's standard name
40 :
41 : ! Dummy arguments
42 : class(ccpp_constituent_prop_ptr_t), intent(in) :: this
43 : character(len=*), intent(out) :: std_name
44 : integer, optional, intent(out) :: errcode
45 : character(len=*), optional, intent(out) :: errmsg
46 :
47 5077440 : std_name = this%std_name
48 :
49 : ! Provide err values if requested:
50 5077440 : if(present(errcode)) then
51 0 : errcode = 0
52 : end if
53 5077440 : if(present(errmsg)) then
54 0 : errmsg = ''
55 : end if
56 :
57 5077440 : end subroutine ccp_get_standard_name
58 :
59 : !------
60 :
61 1536 : subroutine ccp_set_standard_name(this, std_name, errcode, errmsg)
62 : ! Set this constituent's standard name
63 :
64 : ! Dummy arguments
65 : class(ccpp_constituent_prop_ptr_t), intent(inout) :: this
66 : character(len=*), intent(in) :: std_name
67 : integer, optional, intent(out) :: errcode
68 : character(len=*), optional, intent(out) :: errmsg
69 :
70 1536 : this%std_name = std_name
71 :
72 : ! Provide err values if requested:
73 1536 : if(present(errcode)) then
74 0 : errcode = 0
75 : end if
76 1536 : if(present(errmsg)) then
77 0 : errmsg = ''
78 : end if
79 :
80 1536 : end subroutine ccp_set_standard_name
81 :
82 : !------
83 :
84 138614112 : subroutine ccp_is_thermo_active(this, val_out, errcode, errmsg)
85 :
86 : ! Dummy arguments
87 : class(ccpp_constituent_prop_ptr_t), intent(in) :: this
88 : logical, intent(out) :: val_out
89 : integer, optional, intent(out) :: errcode
90 : character(len=*), optional, intent(out) :: errmsg
91 :
92 : ! Pass back thermo active property:
93 138614112 : val_out = this%thermo_active
94 :
95 : ! Provide err values if requested:
96 138614112 : if(present(errcode)) then
97 0 : errcode = 0
98 : end if
99 138614112 : if(present(errmsg)) then
100 0 : errmsg = ''
101 : end if
102 :
103 138614112 : end subroutine ccp_is_thermo_active
104 :
105 : !------
106 :
107 20284992 : subroutine ccp_is_water_species(this, val_out, errcode, errmsg)
108 :
109 : ! Dummy arguments
110 : class(ccpp_constituent_prop_ptr_t), intent(in) :: this
111 : logical, intent(out) :: val_out
112 : integer, optional, intent(out) :: errcode
113 : character(len=*), optional, intent(out) :: errmsg
114 :
115 : ! Pass back water species property:
116 20284992 : val_out = this%water_species
117 :
118 : ! Provide err values if requested:
119 20284992 : if(present(errcode)) then
120 0 : errcode = 0
121 : end if
122 20284992 : if(present(errmsg)) then
123 0 : errmsg = ''
124 : end if
125 :
126 20284992 : end subroutine ccp_is_water_species
127 :
128 : !------
129 :
130 1297224 : subroutine ccp_is_dry(this, val_out, errcode, errmsg)
131 :
132 : ! Dummy arguments
133 : class(ccpp_constituent_prop_ptr_t), intent(in) :: this
134 : logical, intent(out) :: val_out
135 : integer, optional, intent(out) :: errcode
136 : character(len=*), optional, intent(out) :: errmsg
137 :
138 : ! Pass back water species property:
139 1297224 : val_out = this%species_is_dry
140 :
141 : ! Provide err values if requested:
142 1297224 : if(present(errcode)) then
143 1297224 : errcode = 0
144 : end if
145 1297224 : if(present(errmsg)) then
146 1297224 : errmsg = ''
147 : end if
148 :
149 1297224 : end subroutine ccp_is_dry
150 :
151 : !------
152 :
153 9216 : subroutine ccp_set_thermo_active(this, thermo_flag, errcode, errmsg)
154 : ! Set whether this constituent is thermodynamically active, which
155 : ! means that certain physics schemes will use this constitutent
156 : ! when calculating thermodynamic quantities (e.g. enthalpy).
157 :
158 : ! Dummy arguments
159 : class(ccpp_constituent_prop_ptr_t), intent(inout) :: this
160 : logical, intent(in) :: thermo_flag
161 : integer, optional, intent(out) :: errcode
162 : character(len=*), optional, intent(out) :: errmsg
163 :
164 : ! Set thermodynamically active flag for this constituent:
165 9216 : this%thermo_active = thermo_flag
166 :
167 : ! Provide err values if requested:
168 9216 : if(present(errcode)) then
169 0 : errcode = 0
170 : end if
171 9216 : if(present(errmsg)) then
172 0 : errmsg = ''
173 : end if
174 :
175 9216 : end subroutine ccp_set_thermo_active
176 :
177 : !------
178 :
179 9216 : subroutine ccp_set_water_species(this, water_flag, errcode, errmsg)
180 : ! Set whether this constituent is a water species, which means
181 : ! that this constituent represents a particular phase or type
182 : ! of water in the atmosphere.
183 :
184 : ! Dummy arguments
185 : class(ccpp_constituent_prop_ptr_t), intent(inout) :: this
186 : logical, intent(in) :: water_flag
187 : integer, optional, intent(out) :: errcode
188 : character(len=*), optional, intent(out) :: errmsg
189 :
190 : ! Set thermodynamically active flag for this constituent:
191 9216 : this%water_species = water_flag
192 :
193 : ! Provide err values if requested:
194 9216 : if(present(errcode)) then
195 0 : errcode = 0
196 : end if
197 9216 : if(present(errmsg)) then
198 0 : errmsg = ''
199 : end if
200 :
201 9216 : end subroutine ccp_set_water_species
202 :
203 62976 : subroutine ccp_set_dry(this, dry_flag, errcode, errmsg)
204 : ! Set whether this constituent is a dry species or not using the dry_flag which is passed in
205 :
206 : ! Dummy arguments
207 : class(ccpp_constituent_prop_ptr_t), intent(inout) :: this
208 : logical, intent(in) :: dry_flag
209 : integer, optional, intent(out) :: errcode
210 : character(len=*), optional, intent(out) :: errmsg
211 :
212 : ! Set dry_flag for this constituent:
213 62976 : this%species_is_dry = dry_flag
214 :
215 : ! Provide err values if requested:
216 62976 : if(present(errcode)) then
217 0 : errcode = 0
218 : end if
219 62976 : if(present(errmsg)) then
220 0 : errmsg = ''
221 : end if
222 :
223 62976 : end subroutine ccp_set_dry
224 :
225 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
226 : !CAM-equivalent CCPP constituents initialization routine
227 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
228 :
229 1536 : subroutine ccpp_const_props_init(ix_qv)
230 :
231 : ! Use statements:
232 : use constituents, only: pcnst, cnst_get_type_byind
233 : use cam_abortutils, only: handle_allocate_error
234 : use air_composition, only: dry_air_species_num
235 : use air_composition, only: thermodynamic_active_species_idx
236 :
237 : integer, intent(in) :: ix_qv
238 : ! Local variables:
239 : integer :: ierr
240 : integer :: m
241 :
242 : character(len=*), parameter :: subname = 'ccpp_const_prop_init:'
243 :
244 : ! Allocate constituents object:
245 64512 : allocate(ccpp_const_props(pcnst), stat=ierr)
246 :
247 : ! Check if allocation succeeded:
248 1536 : call handle_allocate_error(ierr, subname, 'ccpp_const_props(pcnst)')
249 :
250 : ! Set "thermo_active" property:
251 64512 : do m = 1,pcnst
252 410112 : if(any(thermodynamic_active_species_idx == m)) then
253 9216 : call ccpp_const_props(m)%set_thermo_active(.true.)
254 : end if
255 : end do
256 :
257 : ! Set "water_species" property:
258 64512 : do m=1,pcnst
259 410112 : if(any(thermodynamic_active_species_idx(dry_air_species_num+1:) == m)) then
260 9216 : call ccpp_const_props(m)%set_water_species(.true.)
261 : end if
262 : end do
263 :
264 : ! Set "set_dry" property:
265 64512 : do m=1,pcnst
266 64512 : if (cnst_get_type_byind(m).eq.'dry') then
267 46080 : call ccpp_const_props(m)%set_dry(.true.)
268 : else
269 79872 : call ccpp_const_props(m)%set_dry(.false.)
270 : end if
271 : end do
272 :
273 : ! Set "std_name" property:
274 1536 : call ccpp_const_props(ix_qv)%set_standard_name('water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water')
275 :
276 1536 : end subroutine ccpp_const_props_init
277 :
278 0 : end module ccpp_constituent_prop_mod
|