91#define NUM_REACT_ this%condensed_data_int(1)
92#define NUM_ALKOXY_PROD_ this%condensed_data_int(2)
93#define NUM_NITRATE_PROD_ this%condensed_data_int(3)
94#define X_ this%condensed_data_real(1)
95#define Y_ this%condensed_data_real(2)
96#define a0_ this%condensed_data_real(3)
97#define n_ this%condensed_data_real(4)
98#define CONV_ this%condensed_data_real(5)
99#define NUM_INT_PROP_ 3
100#define NUM_REAL_PROP_ 5
101#define NUM_ENV_PARAM_ 2
102#define REACT_(x) this%condensed_data_int(NUM_INT_PROP_ + x)
103#define PROD_(x) this%condensed_data_int(NUM_INT_PROP_ + NUM_REACT_ + x)
104#define DERIV_ID_(x) this%condensed_data_int(NUM_INT_PROP_ + NUM_REACT_ + NUM_ALKOXY_PROD_ + NUM_NITRATE_PROD_ + x)
105#define JAC_ID_(x) this%condensed_data_int(NUM_INT_PROP_ + 2*(NUM_REACT_ + NUM_ALKOXY_PROD_ + NUM_NITRATE_PROD_) + x)
106#define YIELD_(x) this%condensed_data_real(NUM_REAL_PROP_ + x)
144 subroutine initialize(this, chem_spec_data, aero_phase, aero_rep, n_cells)
155 integer(kind=i_kind),
intent(in) :: n_cells
157 type(
property_t),
pointer :: spec_props, reactants, alkoxy_products, &
159 character(len=:),
allocatable :: key_name, spec_name, string_val
160 integer(kind=i_kind) :: i_spec, i_qty
162 integer(kind=i_kind) :: temp_int
163 real(kind=
dp) :: temp_real
166 if (.not.
associated(this%property_set))
call die_msg(573144252, &
167 "Missing property set needed to initialize reaction")
168 key_name =
"reactants"
170 this%property_set%get_property_t(key_name, reactants), &
171 "Wennberg NO + RO2 reaction is missing reactants")
172 key_name =
"alkoxy products"
174 this%property_set%get_property_t(key_name, alkoxy_products), &
175 "Wennberg NO + RO2 reaction is missing alkoxy products")
176 key_name =
"nitrate products"
178 this%property_set%get_property_t(key_name, nitrate_products), &
179 "Wennberg NO + RO2 reaction is missing nitrate products")
182 call reactants%iter_reset()
186 call assert(626170799, reactants%get_property_t(val=spec_props))
188 if (spec_props%get_int(key_name, temp_int)) i_spec = i_spec+temp_int-1
189 call reactants%iter_next()
194 allocate(this%condensed_data_int(num_int_prop_ + &
195 (i_spec + 2) * (i_spec + alkoxy_products%size() + &
196 nitrate_products%size())))
197 allocate(this%condensed_data_real(num_real_prop_ + &
198 alkoxy_products%size() + nitrate_products%size()))
199 this%condensed_data_int(:) = int(0, kind=
i_kind)
200 this%condensed_data_real(:) = real(0.0, kind=
dp)
203 this%num_env_params = num_env_param_
208 num_alkoxy_prod_ = alkoxy_products%size()
209 num_nitrate_prod_ = nitrate_products%size()
212 conv_ =
const%avagadro /
const%univ_gas_const * 10.0d0**(-12.0d0)
218 if (.not. this%property_set%get_real(key_name, x_))
then
221 key_name =
"time unit"
222 if (this%property_set%get_string(key_name, string_val))
then
223 if (trim(string_val).eq.
"MIN")
then
228 if (.not. this%property_set%get_real(key_name, y_))
then
232 if (.not. this%property_set%get_real(key_name,
a0_))
then
236 if (.not. this%property_set%get_real(key_name,
n_))
then
241 call reactants%iter_reset()
246 react_(i_spec) = chem_spec_data%gas_state_id(
spec_name)
249 call assert_msg(716430972, react_(i_spec).gt.0, &
250 "Missing Wennberg NO + RO2 reactant: "//
spec_name)
253 call assert(493699816, reactants%get_property_t(val=spec_props))
255 if (spec_props%get_int(key_name, temp_int))
then
256 do i_qty = 1, temp_int - 1
257 react_(i_spec + i_qty) = react_(i_spec)
259 i_spec = i_spec + temp_int - 1
262 call reactants%iter_next()
267 call alkoxy_products%iter_reset()
269 do while (alkoxy_products%get_key(
spec_name))
272 prod_(i_spec) = chem_spec_data%gas_state_id(
spec_name)
275 call assert_msg(825390544, prod_(i_spec).gt.0, &
276 "Missing Wennberg NO + RO2 alkoxy product: "//
spec_name)
279 call assert(879870330, alkoxy_products%get_property_t(val=spec_props))
281 if (spec_props%get_real(key_name, temp_real))
then
282 yield_(i_spec) = temp_real
287 call alkoxy_products%iter_next()
290 call nitrate_products%iter_reset()
291 do while (nitrate_products%get_key(
spec_name))
294 prod_(i_spec) = chem_spec_data%gas_state_id(
spec_name)
297 call assert_msg(590677535, prod_(i_spec).gt.0, &
298 "Missing Wennberg NO + RO2 nitrate product: "//
spec_name)
301 call assert(815314225, nitrate_products%get_property_t(val=spec_props))
303 if (spec_props%get_real(key_name, temp_real))
then
304 yield_(i_spec) = temp_real
309 call nitrate_products%iter_next()
312 call assert(699637107, i_spec - 1 .eq. &
313 num_alkoxy_prod_ + num_nitrate_prod_ )
325 if (
associated(this%property_set)) &
326 deallocate(this%property_set)
327 if (
allocated(this%condensed_data_real)) &
328 deallocate(this%condensed_data_real)
329 if (
allocated(this%condensed_data_int)) &
330 deallocate(this%condensed_data_int)
342 integer(kind=i_kind) :: i_rxn
344 do i_rxn = 1,
size(this)
Initialize the aerosol representation data, validating component data and loading any required inform...
Get the non-unique name of a chemical species by its unique name.
Interface for to_string functions.
The abstract aero_phase_data_t structure and associated subroutines.
subroutine finalize_array(this)
Finalize the aerosol phase data.
type(aero_phase_data_t) function, pointer constructor(phase_name, init_size)
Constructor for aero_phase_data_t.
subroutine finalize(this)
Finalize the aerosol phase data.
The abstract aero_rep_data_t structure and associated subroutines.
The camp_state_t structure and associated subroutines.
The chem_spec_data_t structure and associated subroutines.
integer, parameter dp
Kind of a double precision real number.
type(const_t), save const
Fixed variable for accessing the constant's values.
integer, parameter i_kind
Kind of an integer.
The property_t structure and associated subroutines.
The rxn_data_t structure and associated subroutines.
integer(kind=i_kind), parameter, public gas_rxn
Gas-phase reaction.
The rxn_wennberg_no_ro2_t type and associated functions.
Common utility subroutines.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
subroutine die_msg(code, error_msg)
Error immediately.
subroutine assert_msg(code, condition_ok, error_msg)
Errors unless condition_ok is true.
Pointer type for building arrays.
Pointer to aero_rep_data_t extending types.
Abstract reaction data type.
Generic test reaction data type.