CAMP 1.0.0
Chemistry Across Multiple Phases
rxn_condensed_phase_photolysis.F90
Go to the documentation of this file.
1! Copyright (C) 2021 Barcelona Supercomputing Center and University of
2! Illinois at Urbana-Champaign
3! SPDX-License-Identifier: MIT
4
5!> \file
6!> The camp_rxn_condensed_phase_photolysis module.
7
8!> \page camp_rxn_condensed_phase_photolysis CAMP: Condensed-Phase Photolysis Reaction
9!!
10!! Condensed-Phase Photolysis reactions take the form:
11!!
12!! \f[\ce{
13!! X + h $\nu$ -> Y_1 ( + Y_2 \dots )
14!! }\f]
15!!
16!! where \f$\ce{X}\f$ is the species being photolyzed, and
17!! \f$\ce{Y_n}\f$ are the photolysis products.
18!!
19!! The reaction rate can be scaled by providing the "scaling factor" keyword in the json configuration.
20!!
21!!
22!! Input data for condensed-phase Photolysis reactions have the following
23!! format:
24!! \code{.json}
25!! {
26!! "type" : "CONDENSED_PHASE_PHOTOLYSIS",
27!! "rate" : 123.45,
28!! "units" : "M",
29!! "aerosol phase" : "my aqueous phase",
30!! "aerosol-phase water" : "H2O_aq",
31!! "reactants" : {
32!! "spec1" : {},
33!! ...
34!! },
35!! "products" : {
36!! "spec3" : {},
37!! "spec4" : { "yield" : 0.65 },
38!! ...
39!! },
40!! "scaling factor": 11.20
41!! }
42!! \endcode
43!! The key-value pairs \b reactants, and \b products are required. Reactants
44!! without a \b qty value are assumed to appear once in the reaction equation.
45!! Products without a specified \b yield are assumed to have a \b yield of
46!! 1.0.
47!!
48!! Units for the reactants and products must be specified using the key
49!! \b units and can be either \b M or \b mol \b m-3. If units of \b M are
50!! specified, a key-value pair \b aerosol-phase \b water must also be included
51!! whose value is a string specifying the name for water in the aerosol phase.
52!!
53!! The unit for time is assumed to be s, but inclusion of the optional
54!! key-value pair \b time \b unit = \b MIN can be used to indicate a rate
55!! with min as the time unit.
56!!
57!! The key-value pair \b aerosol \b phase is required and must specify the name
58!! of the aerosol-phase in which the reaction occurs.
59
60!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
61
62!> The rxn_condensed_phase_photolysis_t type and associated functions.
64
68 use camp_constants, only: const
70 use camp_mpi
74
75 use iso_c_binding
76
77 implicit none
78 private
79
80#define NUM_REACT_ this%condensed_data_int(1)
81#define NUM_PROD_ this%condensed_data_int(2)
82#define NUM_AERO_PHASE_ this%condensed_data_int(3)
83#define RXN_ID_ this%condensed_data_int(4)
84#define SCALING_ this%condensed_data_real(1)
85#define NUM_REAL_PROP_ 1
86#define NUM_INT_PROP_ 4
87#define NUM_ENV_PARAM_ 2
88#define REACT_(x) this%condensed_data_int(NUM_INT_PROP_+x)
89#define PROD_(x) this%condensed_data_int(NUM_INT_PROP_+NUM_REACT_*NUM_AERO_PHASE_+x)
90#define WATER_(x) this%condensed_data_int(NUM_INT_PROP_+(NUM_REACT_+NUM_PROD_)*NUM_AERO_PHASE_+x)
91#define DERIV_ID_(x) this%condensed_data_int(NUM_INT_PROP_+(NUM_REACT_+NUM_PROD_+1)*NUM_AERO_PHASE_+x)
92#define JAC_ID_(x) this%condensed_data_int(NUM_INT_PROP_+(2*(NUM_REACT_+NUM_PROD_)+1)*NUM_AERO_PHASE_+x)
93#define YIELD_(x) this%condensed_data_real(NUM_REAL_PROP_+x)
94#define KGM3_TO_MOLM3_(x) this%condensed_data_real(NUM_REAL_PROP_+NUM_PROD_+x)
95
97
98 !> Generic test reaction data type
100 contains
101 !> Reaction initialization
102 procedure :: initialize
103 !> Get the reaction property set
104 procedure :: get_property_set
105 !> Initialize update data
107 !> Finalize the reaction
110
111 !> Constructor for rxn_condensed_phase_photolysis_t
113 procedure :: constructor
115
116 !> Condensed-phase Photolysis rate update object
118 private
119 !> Flag indicating whether the update data as been allocated
120 logical :: is_malloced = .false.
121 !> Unique id for finding reactions during model initialization
122 integer(kind=i_kind) :: rxn_unique_id = 0
123 contains
124 !> Update the rate data
125 procedure :: set_rate => update_data_rate_set
126 !> Determine the pack size of the local update data
128 !> Pack the local update data to a binary
129 procedure :: internal_bin_pack
130 !> Unpack the local update data from a binary
132 !> Finalize the rate update data
135
136 !> Interface to c reaction functions
137 interface
138
139 !> Allocate space for a rate update
141 bind (c)
142 use iso_c_binding
143 !> Allocated update_data object
144 type(c_ptr) :: update_data
146
147 !> Set a new photolysis rate
148 subroutine rxn_condensed_phase_photolysis_set_rate_update_data(update_data, photo_id, &
149 base_rate) bind (c)
150 use iso_c_binding
151 !> Update data
152 type(c_ptr), value :: update_data
153 !> Photo id
154 integer(kind=c_int), value :: photo_id
155 !> New pre-scaling base photolysis rate
156 real(kind=c_double), value :: base_rate
158
159 !> Free an update rate data object
160 pure subroutine rxn_free_update_data(update_data) bind (c)
161 use iso_c_binding
162 !> Update data
163 type(c_ptr), value, intent(in) :: update_data
164 end subroutine rxn_free_update_data
165
166 end interface
167
168contains
169
170!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
171
172 !> Constructor for Condensed-phase Photolysis reaction
173 function constructor() result(new_obj)
174
175 !> A new reaction instance
176 type(rxn_condensed_phase_photolysis_t), pointer :: new_obj
177
178 allocate(new_obj)
179 new_obj%rxn_phase = aero_rxn
180
181 end function constructor
182
183!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
184
185 !> Initialize the reaction data, validating component data and loading
186 !! any required information into the condensed data arrays for use during
187 !! solving
188 subroutine initialize(this, chem_spec_data, aero_phase, aero_rep, n_cells)
189
190 !> Reaction data
191 class(rxn_condensed_phase_photolysis_t), intent(inout) :: this
192 !> Chemical species data
193 type(chem_spec_data_t), intent(in) :: chem_spec_data
194 !> Aerosol phase data
195 type(aero_phase_data_ptr), intent(in) :: aero_phase(:)
196 !> Aerosol representations
197 type(aero_rep_data_ptr), pointer, intent(in) :: aero_rep(:)
198 !> Number of grid cells to solve simultaneously
199 integer(kind=i_kind), intent(in) :: n_cells
200
201 type(property_t), pointer :: spec_props, reactants, products
202 character(len=:), allocatable :: key_name, spec_name, water_name, &
203 phase_name, temp_string
204 integer(kind=i_kind) :: i_spec, i_phase_inst, i_qty, i_aero_rep, &
205 i_aero_phase, num_spec_per_phase, num_phase, num_react, num_prod
206 type(string_t), allocatable :: unique_names(:)
207 type(string_t), allocatable :: react_names(:), prod_names(:)
208
209 integer(kind=i_kind) :: temp_int
210 real(kind=dp) :: temp_real
211 logical :: is_aqueous
212
213 is_aqueous = .false.
214
215 ! Get the property set
216 call assert_msg(852163263, associated(this%property_set), &
217 "Missing property set needed to initialize reaction")
218
219 ! Get the aerosol phase name
220 key_name = "aerosol phase"
221 call assert_msg(845445717, &
222 this%property_set%get_string(key_name, phase_name), &
223 "Missing aerosol phase in condensed-phase Photolysis reaction")
224
225 ! Get reactant species
226 key_name = "reactants"
227 call assert_msg(501773136, &
228 this%property_set%get_property_t(key_name, reactants), &
229 "Missing reactant species in condensed-phase Photolysis reaction")
230
231 ! Get product species
232 key_name = "products"
233 call assert_msg(556252922, &
234 this%property_set%get_property_t(key_name, products), &
235 "Missing product species in condensed-phase Photolysis reaction")
236
237 ! Count the number of species per phase instance (including reactants
238 ! with a "qty" specified)
239 call reactants%iter_reset()
240 num_react = 0
241 do while (reactants%get_key(spec_name))
242 ! Get properties included with this reactant in the reaction data
243 call assert(428593951, reactants%get_property_t(val=spec_props))
244 key_name = "qty"
245 if (spec_props%get_int(key_name, temp_int)) &
246 num_react = num_react + temp_int - 1
247 call reactants%iter_next()
248 num_react = num_react + 1
249 end do
250
251 ! Photolysis reactions only have 1 reactant, enforce that here
252 call assert_msg(890212987, num_react .eq. 1, &
253 "Too many species in condensed-phase Photolysis reaction. Only one reactant is expected.")
254
255 num_prod = products%size()
256 num_spec_per_phase = num_prod + num_react
257
258 ! Check for aerosol representations
259 call assert_msg(370755392, associated(aero_rep), &
260 "Missing aerosol representation for condensed-phase "// &
261 "Photolysis reaction")
262 call assert_msg(483073737, size(aero_rep).gt.0, &
263 "Missing aerosol representation for condensed-phase "// &
264 "Photolysis reaction")
265
266 ! Count the instances of the specified aerosol phase
267 num_phase = 0
268 do i_aero_rep = 1, size(aero_rep)
269 num_phase = num_phase + &
270 aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
271 end do
272
273 ! Allocate space in the condensed data arrays
274 allocate(this%condensed_data_int(num_int_prop_ + &
275 num_phase * (num_spec_per_phase * (num_react + 3) + 1)))
276 allocate(this%condensed_data_real(num_real_prop_ + &
277 num_spec_per_phase + num_prod))
278 this%condensed_data_int(:) = int(0, kind=i_kind)
279 this%condensed_data_real(:) = real(0.0, kind=dp)
280
281 ! Save space for the environment-dependent parameters
282 this%num_env_params = num_env_param_
283
284 ! Set the number of products, reactants and aerosol phase instances
285 num_react_ = num_react
286 num_prod_ = num_prod
287 num_aero_phase_ = num_phase
288
289 ! Get reaction parameters (it might be easiest to keep these at the
290 ! beginning of the condensed data array, so they can be accessed using
291 ! compliler flags)
292 key_name = "scaling factor"
293 if (.not. this%property_set%get_real(key_name, scaling_)) then
294 scaling_ = real(1.0, kind=dp)
295 end if
296
297 ! Set up an array to the reactant and product names
298 allocate(react_names(num_react_))
299 allocate(prod_names(num_prod_))
300
301 ! Get the chemical properties for the reactants
302 call reactants%iter_reset()
303 i_spec = 0
304 do while (reactants%get_key(spec_name))
305
306 ! Get the reactant species properties
307 call assert_msg(365229559, &
308 chem_spec_data%get_property_set(spec_name, spec_props), &
309 "Missing properties required for condensed-phase Photolysis "// &
310 "reaction involving species '"//trim(spec_name)//"'")
311
312 ! Get the molecular weight
313 key_name = "molecular weight [kg mol-1]"
314 call assert_msg(409180731, spec_props%get_real(key_name, temp_real), &
315 "Missing 'molecular weight' for species '"//trim(spec_name)// &
316 "' in condensed-phase Photolysis reaction.")
317
318 ! Set properties for each occurance of a reactant in the rxn equation
319 call assert(186449575, reactants%get_property_t(val=spec_props))
320 key_name = "qty"
321 if (.not.spec_props%get_int(key_name, temp_int)) temp_int = 1
322 do i_qty = 1, temp_int
323 i_spec = i_spec + 1
324
325 ! Add the reactant name to the list
326 react_names(i_spec)%string = spec_name
327
328 ! Use the MW to calculate the kg/m3 -> mol/m3 conversion
329 kgm3_to_molm3_(i_spec) = 1.0/temp_real
330
331 end do
332
333 ! Go to the next reactant
334 call reactants%iter_next()
335
336 end do
337
338 ! Get the chemical properties for the products
339 call products%iter_reset()
340 i_spec = 0
341 do while (products%get_key(spec_name))
342
343 ! Get the product species properties
344 call assert_msg(450225425, &
345 chem_spec_data%get_property_set(spec_name, spec_props), &
346 "Missing properties required for condensed-phase Photolysis "// &
347 "reaction involving species '"//trim(spec_name)//"'")
348
349 ! Increment the product counter
350 i_spec = i_spec + 1
351
352 ! Get the molecular weight
353 key_name = "molecular weight [kg mol-1]"
354 call assert_msg(504705211, spec_props%get_real(key_name, temp_real), &
355 "Missing 'molecular weight' for species '"//trim(spec_name)// &
356 "' in condensed phase Photolysis reaction.")
357
358 ! Use the MW to calculate the kg/m3 -> mol/m3 conversion
359 kgm3_to_molm3_(num_react_+i_spec) = 1.0/temp_real
360
361 ! Set properties for each occurance of a reactant in the rxn equation
362 call assert(846924553, products%get_property_t(val=spec_props))
363 key_name = "yield"
364 if (spec_props%get_real(key_name, temp_real)) then
365 yield_(i_spec) = temp_real
366 else
367 yield_(i_spec) = 1.0d0
368 end if
369
370 ! Add the product name to the list
371 prod_names(i_spec)%string = spec_name
372
373 ! Go to the next product
374 call products%iter_next()
375
376 end do
377
378 ! Get the units for the reactants and products and name for water
379 ! if this is an aqueous reaction
380 key_name = "units"
381 call assert_msg(348722817, &
382 this%property_set%get_string(key_name, temp_string), &
383 "Missing units for condensed-phase Photolysis reaction.")
384 if (trim(temp_string).eq."mol m-3") then
385 is_aqueous = .false.
386 key_name = "aerosol-phase water"
387 call assert_msg(767767240, &
388 .not.this%property_set%get_string(key_name, temp_string), &
389 "Aerosol-phase water specified for non-aqueous condensed-"// &
390 "phase Photolysis reaction. Change units to 'M' or remove "// &
391 "aerosol-phase water")
392 else if (trim(temp_string).eq."M") then
393 is_aqueous = .true.
394 key_name = "aerosol-phase water"
395 call assert_msg(199910264, &
396 this%property_set%get_string(key_name, water_name), &
397 "Missing aerosol-phase water for aqeuous condensed-phase "// &
398 "Photolysis reaction.")
399 else
400 call die_msg(161772048, "Received invalid units for condensed-"// &
401 "phase Photolysis reaction: '"//temp_string//"'. Valid "// &
402 "units are 'mol m-3' or 'M'.")
403 end if
404
405 ! Set the state array indices for the reactants, products and water
406 i_aero_phase = 0
407 do i_aero_rep = 1, size(aero_rep)
408
409 ! Check for the specified phase in this aero rep
410 num_phase = aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
411 if (num_phase.eq.0) cycle
412
413 ! Save the state ids for aerosol-phase water for aqueous reactions.
414 ! For non-aqueous reactions, set the water id to -1
415 if (is_aqueous) then
416
417 ! Get the unique names for aerosol-phase water
418 unique_names = aero_rep(i_aero_rep)%val%unique_names( &
419 phase_name = phase_name, spec_name = water_name)
420
421 ! Make sure water is present
422 call assert_msg(196838614, size(unique_names).eq.num_phase, &
423 "Missing aerosol-phase water species '"//water_name// &
424 "' in phase '"//phase_name//"' in aqueous condensed-"// &
425 "phase Photolysis reacion.")
426
427 ! Save the ids for water in this phase
428 do i_phase_inst = 1, num_phase
429 water_(i_aero_phase + i_phase_inst) = &
430 aero_rep(i_aero_rep)%val%spec_state_id( &
431 unique_names(i_phase_inst)%string)
432 end do
433
434 deallocate(unique_names)
435
436 else
437
438 ! Set the water ids to -1 for non-aqueous condensed-phase reactions
439 do i_phase_inst = 1, num_phase
440 water_(i_aero_phase + i_phase_inst) = -1
441 end do
442
443 end if
444
445 ! Loop through the reactants
446 do i_spec = 1, num_react_
447
448 ! Get the unique names for the reactants
449 unique_names = aero_rep(i_aero_rep)%val%unique_names( &
450 phase_name = phase_name, spec_name = react_names(i_spec)%string)
451
452 ! Make sure the right number of instances are present
453 call assert_msg(360730267, size(unique_names).eq.num_phase, &
454 "Incorrect instances of reactant '"// &
455 react_names(i_spec)%string//"' in phase '"//phase_name// &
456 "' in a condensed-phase Photolysis reaction")
457
458 ! Save the state ids for the reactant concentration
459 ! IDs are grouped by phase instance:
460 ! R1(phase1), R2(phase1), ..., R1(phase2)...
461 do i_phase_inst = 1, num_phase
462 react_((i_aero_phase+i_phase_inst-1)*num_react_ + i_spec) = &
463 aero_rep(i_aero_rep)%val%spec_state_id( &
464 unique_names(i_phase_inst)%string)
465 end do
466
467 deallocate(unique_names)
468
469 end do
470
471 ! Loop through the products
472 do i_spec = 1, num_prod_
473
474 ! Get the unique names for the products
475 unique_names = aero_rep(i_aero_rep)%val%unique_names( &
476 phase_name = phase_name, spec_name = prod_names(i_spec)%string)
477
478 ! Make sure the right number of instances are present
479 call assert_msg(399869427, size(unique_names).eq.num_phase, &
480 "Incorrect instances of product '"// &
481 prod_names(i_spec)%string//"' in phase '"//phase_name// &
482 "' in a condensed-phase Photolysis reaction")
483
484 ! Save the state ids for the product concentration
485 ! IDs are grouped by phase instance:
486 ! P1(phase1), P2(phase1), ..., P1(phase2)...
487 do i_phase_inst = 1, num_phase
488 prod_((i_aero_phase+i_phase_inst-1)*num_prod_ + i_spec) = &
489 aero_rep(i_aero_rep)%val%spec_state_id( &
490 unique_names(i_phase_inst)%string)
491 end do
492
493 deallocate(unique_names)
494
495 end do
496
497 ! Increment the index offset for the next aerosol representation
498 i_aero_phase = i_aero_phase + num_phase
499
500 end do
501
502 ! Initialize the reaction id
503 rxn_id_ = -1
504
505 end subroutine initialize
506
507!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
508
509 !> Get the reaction properties. (For use by external photolysis modules.)
510 function get_property_set(this) result(prop_set)
511
512 !> Reaction properties
513 type(property_t), pointer :: prop_set
514 !> Reaction data
515 class(rxn_condensed_phase_photolysis_t), intent(in) :: this
516
517 prop_set => this%property_set
518
519 end function get_property_set
520
521!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
522
523 !> Finalize the reaction
524 subroutine finalize(this)
525
526 !> Reaction data
527 type(rxn_condensed_phase_photolysis_t), intent(inout) :: this
528
529 if (associated(this%property_set)) &
530 deallocate(this%property_set)
531 if (allocated(this%condensed_data_real)) &
532 deallocate(this%condensed_data_real)
533 if (allocated(this%condensed_data_int)) &
534 deallocate(this%condensed_data_int)
535
536 end subroutine finalize
537
538!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
539
540 !> Finalize an array of reactions
541 subroutine finalize_array(this)
542
543 !> Reaction data
544 type(rxn_condensed_phase_photolysis_t), intent(inout) :: this(:)
545
546 integer(kind=i_kind) :: i
547
548 do i = 1, size(this)
549 call finalize(this(i))
550 end do
551
552 end subroutine finalize_array
553
554!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
555
556 !> Set packed update data for photolysis rate constants
557 subroutine update_data_rate_set(this, base_rate)
558
559 !> Update data
560 class(rxn_update_data_condensed_phase_photolysis_t), intent(inout) :: this
561 !> Updated pre-scaling photolysis rate
562 real(kind=dp), intent(in) :: base_rate
563
565 this%rxn_unique_id, base_rate)
566
567 end subroutine update_data_rate_set
568
569!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
570
571 !> Initialize update data
572 subroutine update_data_initialize(this, update_data, rxn_type)
573
574 use camp_rand, only : generate_int_id
575
576 !> The reaction to update
577 class(rxn_condensed_phase_photolysis_t), intent(inout) :: this
578 !> Update data object
579 class(rxn_update_data_condensed_phase_photolysis_t), intent(out) :: update_data
580 !> Reaction type id
581 integer(kind=i_kind), intent(in) :: rxn_type
582
583 ! If a reaction id has not yet been generated, do it now
584 if (rxn_id_.eq.-1) then
585 rxn_id_ = generate_int_id()
586 endif
587
588 update_data%rxn_unique_id = rxn_id_
589 update_data%rxn_type = int(rxn_type, kind=c_int)
591 update_data%is_malloced = .true.
592
593 end subroutine update_data_initialize
594
595!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
596
597 !> Determine the size of a binary required to pack the reaction data
598 integer(kind=i_kind) function internal_pack_size(this, comm) &
599 result(pack_size)
600
601 !> Reaction update data
602 class(rxn_update_data_condensed_phase_photolysis_t), intent(in) :: this
603 !> MPI communicator
604 integer, intent(in) :: comm
605
606 pack_size = &
607 camp_mpi_pack_size_logical(this%is_malloced, comm) + &
608 camp_mpi_pack_size_integer(this%rxn_unique_id, comm)
609
610 end function internal_pack_size
611
612!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
613
614 !> Pack the given value to the buffer, advancing position
615 subroutine internal_bin_pack(this, buffer, pos, comm)
616
617 !> Reaction update data
618 class(rxn_update_data_condensed_phase_photolysis_t), intent(in) :: this
619 !> Memory buffer
620 character, intent(inout) :: buffer(:)
621 !> Current buffer position
622 integer, intent(inout) :: pos
623 !> MPI communicator
624 integer, intent(in) :: comm
625
626#ifdef CAMP_USE_MPI
627 integer :: prev_position
628
629 prev_position = pos
630 call camp_mpi_pack_logical(buffer, pos, this%is_malloced, comm)
631 call camp_mpi_pack_integer(buffer, pos, this%rxn_unique_id, comm)
632 call assert(649543400, &
633 pos - prev_position <= this%pack_size(comm))
634#endif
635
636 end subroutine internal_bin_pack
637
638!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
639
640 !> Unpack the given value from the buffer, advancing position
641 subroutine internal_bin_unpack(this, buffer, pos, comm)
642
643 !> Reaction update data
644 class(rxn_update_data_condensed_phase_photolysis_t), intent(inout) :: this
645 !> Memory buffer
646 character, intent(inout) :: buffer(:)
647 !> Current buffer position
648 integer, intent(inout) :: pos
649 !> MPI communicator
650 integer, intent(in) :: comm
651
652#ifdef CAMP_USE_MPI
653 integer :: prev_position
654
655 prev_position = pos
656 call camp_mpi_unpack_logical(buffer, pos, this%is_malloced, comm)
657 call camp_mpi_unpack_integer(buffer, pos, this%rxn_unique_id, comm)
658 call assert(254749806, &
659 pos - prev_position <= this%pack_size(comm))
661#endif
662
663 end subroutine internal_bin_unpack
664
665!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
666
667 !> Finalize an update data object
668 subroutine update_data_finalize(this)
669
670 !> Update data object to free
671 type(rxn_update_data_condensed_phase_photolysis_t), intent(inout) :: this
672
673 if (this%is_malloced) call rxn_free_update_data(this%update_data)
674
675 end subroutine update_data_finalize
676
677!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
678
679 !> Finalize an array of update data objects
681
682 !> Update data object to free
683 type(rxn_update_data_condensed_phase_photolysis_t), intent(inout) :: this(:)
684
685 integer(kind=i_kind) :: i
686
687 do i = 1, size(this)
688 call update_data_finalize(this(i))
689 end do
690
691 end subroutine update_data_finalize_array
692
693!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
694
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.
Get a list of unique names for each element on the camp_camp_state::camp_state_t::state_var array for...
Interface for to_string functions.
Definition util.F90:32
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.
Definition camp_state.F90:9
The chem_spec_data_t structure and associated subroutines.
Physical constants.
Definition constants.F90:9
integer, parameter dp
Kind of a double precision real number.
Definition constants.F90:16
type(const_t), save const
Fixed variable for accessing the constant's values.
Definition constants.F90:77
integer, parameter i_kind
Kind of an integer.
Definition constants.F90:21
Wrapper functions for MPI.
Definition mpi.F90:13
subroutine camp_mpi_pack_logical(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
Definition mpi.F90:792
subroutine camp_mpi_unpack_integer(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
Definition mpi.F90:1023
subroutine camp_mpi_unpack_logical(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
Definition mpi.F90:1131
integer function camp_mpi_pack_size_logical(val, comm)
Determines the number of bytes required to pack the given value.
Definition mpi.F90:484
subroutine camp_mpi_pack_integer(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
Definition mpi.F90:691
integer function camp_mpi_pack_size_integer(val, comm)
Determines the number of bytes required to pack the given value.
Definition mpi.F90:398
The property_t structure and associated subroutines.
Definition property.F90:9
Random number generators.
Definition rand.F90:9
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.
Definition rand.F90:435
The rxn_condensed_phase_photolysis_t type and associated functions.
subroutine update_data_finalize_array(this)
Finalize an array of update data objects.
subroutine update_data_initialize(this, update_data, rxn_type)
Initialize update data.
subroutine update_data_finalize(this)
Finalize an update data object.
subroutine update_data_rate_set(this, base_rate)
Set packed update data for photolysis rate constants.
The rxn_data_t structure and associated subroutines.
Definition rxn_data.F90:60
integer(kind=i_kind), parameter, public aero_rxn
Aerosol-phase reaction.
Definition rxn_data.F90:89
Common utility subroutines.
Definition util.F90:9
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
Definition util.F90:165
subroutine die_msg(code, error_msg)
Error immediately.
Definition util.F90:196
subroutine assert_msg(code, condition_ok, error_msg)
Errors unless condition_ok is true.
Definition util.F90:130
Pointer type for building arrays.
Pointer to aero_rep_data_t extending types.
Abstract reaction data type.
Definition rxn_data.F90:99
String type for building arrays of string of various size.
Definition util.F90:53