79#define NUM_REACT_ this%condensed_data_int(1)
80#define NUM_PROD_ this%condensed_data_int(2)
81#define RXN_ID_ this%condensed_data_int(3)
82#define SCALING_ this%condensed_data_real(1)
83#define NUM_INT_PROP_ 3
84#define NUM_REAL_PROP_ 1
85#define NUM_ENV_PARAM_ 2
86#define REACT_(x) this%condensed_data_int(NUM_INT_PROP_ + x)
87#define PROD_(x) this%condensed_data_int(NUM_INT_PROP_ + NUM_REACT_ + x)
88#define DERIV_ID_(x) this%condensed_data_int(NUM_INT_PROP_ + NUM_REACT_ + NUM_PROD_ + x)
89#define JAC_ID_(x) this%condensed_data_int(NUM_INT_PROP_ + 2*(NUM_REACT_+NUM_PROD_) + x)
90#define YIELD_(x) this%condensed_data_real(NUM_REAL_PROP_ + x)
109 procedure :: constructor
116 logical :: is_malloced = .false.
118 integer(kind=i_kind) :: rxn_unique_id = 0
140 type(c_ptr) :: update_data
148 type(c_ptr),
value :: update_data
150 integer(kind=c_int),
value :: photo_id
152 real(kind=c_double),
value :: base_rate
159 type(c_ptr),
value,
intent(in) :: update_data
184 subroutine initialize(this, chem_spec_data, aero_phase, aero_rep, n_cells)
195 integer(kind=i_kind),
intent(in) :: n_cells
197 type(
property_t),
pointer :: spec_props, reactants, products
198 character(len=:),
allocatable :: key_name, spec_name
199 integer(kind=i_kind) :: i_spec, i_qty
201 integer(kind=i_kind) :: temp_int
202 real(kind=
dp) :: temp_real
205 if (.not.
associated(this%property_set))
call die_msg(408416753, &
206 "Missing property set needed to initialize reaction")
207 key_name =
"reactants"
209 this%property_set%get_property_t(key_name, reactants), &
210 "Photolysis reaction is missing reactants")
211 key_name =
"products"
213 this%property_set%get_property_t(key_name, products), &
214 "Photolysis reaction is missing products")
217 call reactants%iter_reset()
221 call assert(240165383, reactants%get_property_t(val=spec_props))
223 if (spec_props%get_int(key_name, temp_int)) i_spec = i_spec+temp_int-1
224 call reactants%iter_next()
232 allocate(this%condensed_data_int(num_int_prop_ + &
233 (i_spec + 2) * (i_spec + products%size())))
234 allocate(this%condensed_data_real(num_real_prop_ + products%size()))
235 this%condensed_data_int(:) = int(0, kind=
i_kind)
236 this%condensed_data_real(:) = real(0.0, kind=
dp)
239 this%num_env_params = num_env_param_
244 num_prod_ = products%size()
249 key_name =
"scaling factor"
250 if (.not. this%property_set%get_real(key_name, scaling_))
then
251 scaling_ = real(1.0, kind=
dp)
255 call reactants%iter_reset()
260 react_(i_spec) = chem_spec_data%gas_state_id(
spec_name)
263 call assert_msg(747277322, react_(i_spec).gt.0, &
264 "Missing photolysis reactant: "//
spec_name)
267 call assert(231542303, reactants%get_property_t(val=spec_props))
269 if (spec_props%get_int(key_name, temp_int))
then
270 do i_qty = 1, temp_int - 1
271 react_(i_spec + i_qty) = react_(i_spec)
273 i_spec = i_spec + temp_int - 1
276 call reactants%iter_next()
281 call assert_msg(908486656, i_spec.eq.2,
"Incorrect number of reactants"//&
282 " for Photolysis reaction: "//
to_string(i_spec-1))
285 call products%iter_reset()
290 prod_(i_spec) = chem_spec_data%gas_state_id(
spec_name)
293 call assert_msg(360988742, prod_(i_spec).gt.0, &
294 "Missing photolysis product: "//
spec_name)
297 call assert(173703744, products%get_property_t(val=spec_props))
299 if (spec_props%get_real(key_name, temp_real))
then
300 yield_(i_spec) = temp_real
305 call products%iter_next()
324 prop_set => this%property_set
336 if (
associated(this%property_set)) &
337 deallocate(this%property_set)
338 if (
allocated(this%condensed_data_real)) &
339 deallocate(this%condensed_data_real)
340 if (
allocated(this%condensed_data_int)) &
341 deallocate(this%condensed_data_int)
353 integer(kind=i_kind) :: i
369 real(kind=
dp),
intent(in) :: base_rate
372 this%rxn_unique_id, base_rate)
388 integer(kind=i_kind),
intent(in) :: rxn_type
391 if (rxn_id_.eq.-1)
then
395 update_data%rxn_unique_id = rxn_id_
396 update_data%rxn_type = int(rxn_type, kind=c_int)
398 update_data%is_malloced = .true.
411 integer,
intent(in) :: comm
427 character,
intent(inout) :: buffer(:)
429 integer,
intent(inout) :: pos
431 integer,
intent(in) :: comm
434 integer :: prev_position
440 pos - prev_position <= this%pack_size(comm))
453 character,
intent(inout) :: buffer(:)
455 integer,
intent(inout) :: pos
457 integer,
intent(in) :: comm
460 integer :: prev_position
466 pos - prev_position <= this%pack_size(comm))
492 integer(kind=i_kind) :: i
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_phase_data_t structure and associated subroutines.
subroutine finalize_array(this)
Finalize the aerosol phase data.
class(property_t) function, pointer get_property_set(this)
Get the aerosol phase property set.
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.
integer(kind=i_kind) function pack_size(this, comm)
Determine the size of a binary required to pack the aerosol representation 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.
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.
subroutine update_data_finalize(this)
Finalize an update data object.
subroutine update_data_finalize_array(this)
Finalize an array of update data objects.
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.
Photolysis rate update object.