78#define NUM_REACT_ this%condensed_data_int(1)
79#define NUM_PROD_ this%condensed_data_int(2)
80#define RXN_ID_ this%condensed_data_int(3)
81#define SCALING_ this%condensed_data_real(1)
82#define NUM_INT_PROP_ 3
83#define NUM_REAL_PROP_ 1
84#define NUM_ENV_PARAM_ 2
85#define REACT_(x) this%condensed_data_int(NUM_INT_PROP_ + x)
86#define PROD_(x) this%condensed_data_int(NUM_INT_PROP_ + NUM_REACT_ + x)
87#define DERIV_ID_(x) this%condensed_data_int(NUM_INT_PROP_ + NUM_REACT_ + NUM_PROD_ + x)
88#define JAC_ID_(x) this%condensed_data_int(NUM_INT_PROP_ + 2*(NUM_REACT_+NUM_PROD_) + x)
89#define YIELD_(x) this%condensed_data_real(NUM_REAL_PROP_ + x)
115 logical :: is_malloced = .false.
117 integer(kind=i_kind) :: rxn_unique_id = 0
139 type(c_ptr) :: update_data
147 type(c_ptr),
value :: update_data
149 integer(kind=c_int),
value :: photo_id
151 real(kind=c_double),
value :: base_rate
158 type(c_ptr),
value,
intent(in) :: update_data
183 subroutine initialize(this, chem_spec_data, aero_rep, n_cells)
192 integer(kind=i_kind),
intent(in) :: n_cells
194 type(
property_t),
pointer :: spec_props, reactants, products
195 character(len=:),
allocatable :: key_name, spec_name
196 integer(kind=i_kind) :: i_spec, i_qty
198 integer(kind=i_kind) :: temp_int
199 real(kind=
dp) :: temp_real
202 if (.not.
associated(this%property_set))
call die_msg(408416753, &
203 "Missing property set needed to initialize reaction")
204 key_name =
"reactants"
206 this%property_set%get_property_t(key_name, reactants), &
207 "Photolysis reaction is missing reactants")
208 key_name =
"products"
210 this%property_set%get_property_t(key_name, products), &
211 "Photolysis reaction is missing products")
214 call reactants%iter_reset()
218 call assert(240165383, reactants%get_property_t(val=spec_props))
220 if (spec_props%get_int(key_name, temp_int)) i_spec = i_spec+temp_int-1
221 call reactants%iter_next()
229 allocate(this%condensed_data_int(num_int_prop_ + &
230 (i_spec + 2) * (i_spec + products%size())))
231 allocate(this%condensed_data_real(num_real_prop_ + products%size()))
232 this%condensed_data_int(:) = int(0, kind=
i_kind)
233 this%condensed_data_real(:) = real(0.0, kind=
dp)
236 this%num_env_params = num_env_param_
241 num_prod_ = products%size()
246 key_name =
"scaling factor"
247 if (.not. this%property_set%get_real(key_name, scaling_))
then
248 scaling_ = real(1.0, kind=
dp)
252 call reactants%iter_reset()
257 react_(i_spec) = chem_spec_data%gas_state_id(
spec_name)
260 call assert_msg(747277322, react_(i_spec).gt.0, &
261 "Missing photolysis reactant: "//
spec_name)
264 call assert(231542303, reactants%get_property_t(val=spec_props))
266 if (spec_props%get_int(key_name, temp_int))
then
267 do i_qty = 1, temp_int - 1
268 react_(i_spec + i_qty) = react_(i_spec)
270 i_spec = i_spec + temp_int - 1
273 call reactants%iter_next()
278 call assert_msg(908486656, i_spec.eq.2,
"Incorrect number of reactants"//&
279 " for Photolysis reaction: "//
to_string(i_spec-1))
282 call products%iter_reset()
287 prod_(i_spec) = chem_spec_data%gas_state_id(
spec_name)
290 call assert_msg(360988742, prod_(i_spec).gt.0, &
291 "Missing photolysis product: "//
spec_name)
294 call assert(173703744, products%get_property_t(val=spec_props))
296 if (spec_props%get_real(key_name, temp_real))
then
297 yield_(i_spec) = temp_real
302 call products%iter_next()
321 prop_set => this%property_set
333 if (
associated(this%property_set)) &
334 deallocate(this%property_set)
335 if (
allocated(this%condensed_data_real)) &
336 deallocate(this%condensed_data_real)
337 if (
allocated(this%condensed_data_int)) &
338 deallocate(this%condensed_data_int)
350 real(kind=
dp),
intent(in) :: base_rate
353 this%rxn_unique_id, base_rate)
369 integer(kind=i_kind),
intent(in) :: rxn_type
372 if (rxn_id_.eq.-1)
then
376 update_data%rxn_unique_id = rxn_id_
377 update_data%rxn_type = int(rxn_type, kind=c_int)
379 update_data%is_malloced = .true.
392 integer,
intent(in) :: comm
408 character,
intent(inout) :: buffer(:)
410 integer,
intent(inout) :: pos
412 integer,
intent(in) :: comm
415 integer :: prev_position
421 pos - prev_position <= this%pack_size(comm))
434 character,
intent(inout) :: buffer(:)
436 integer,
intent(inout) :: pos
438 integer,
intent(in) :: comm
441 integer :: prev_position
447 pos - prev_position <= this%pack_size(comm))
Initialize the aerosol representation data, validating component data and loading any required inform...
Extending-type binary pack function (Internal use only)
Extending-type binary unpack function (Internal use only)
Extending-type binary pack size (internal use only)
Get the non-unique name of a chemical species by its unique name.
Free an update rate data object.
Interface to c reaction functions.
Set a new photolysis rate.
Interface for to_string functions.
The abstract aero_rep_data_t structure and associated subroutines.
integer(kind=i_kind) function pack_size(this, comm)
Determine the size of a binary required to pack the aerosol representation data.
The camp_state_t structure and associated subroutines.
elemental subroutine finalize(this)
Finalize the state.
The chem_spec_data_t structure and associated subroutines.
type(chem_spec_data_t) function, pointer constructor(init_size)
Constructor for chem_spec_data_t.
logical function get_property_set(this, spec_name, property_set)
Get a species property set. Returns true if the species is found, or false otherwise.
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.
Wrapper functions for MPI.
subroutine camp_mpi_pack_logical(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
subroutine camp_mpi_unpack_integer(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
subroutine camp_mpi_unpack_logical(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
integer function camp_mpi_pack_size_logical(val, comm)
Determines the number of bytes required to pack the given value.
subroutine camp_mpi_pack_integer(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
integer function camp_mpi_pack_size_integer(val, comm)
Determines the number of bytes required to pack the given value.
The property_t structure and associated subroutines.
Random number generators.
integer(kind=i_kind) function generate_int_id()
Generate an integer id Ids will be sequential, and can only be generated by the primary process.
The rxn_data_t structure and associated subroutines.
integer(kind=i_kind), parameter, public gas_rxn
Gas-phase reaction.
The rxn_photolysis_t type and associated functions.
subroutine update_data_initialize(this, update_data, rxn_type)
Initialize update data.
subroutine update_data_rate_set(this, base_rate)
Set packed update data for photolysis rate constants.
elemental subroutine update_data_finalize(this)
Finalize an update data object.
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 to aero_rep_data_t extending types.
Abstract reaction data type.
Generic test reaction data type.
Photolysis rate update object.