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
108 final :: finalize
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_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 representations
195 type(aero_rep_data_ptr), pointer, intent(in) :: aero_rep(:)
196 !> Number of grid cells to solve simultaneously
197 integer(kind=i_kind), intent(in) :: n_cells
198
199 type(property_t), pointer :: spec_props, reactants, products
200 character(len=:), allocatable :: key_name, spec_name, water_name, &
201 phase_name, temp_string
202 integer(kind=i_kind) :: i_spec, i_phase_inst, i_qty, i_aero_rep, &
203 i_aero_phase, num_spec_per_phase, num_phase, num_react, num_prod
204 type(string_t), allocatable :: unique_names(:)
205 type(string_t), allocatable :: react_names(:), prod_names(:)
206
207 integer(kind=i_kind) :: temp_int
208 real(kind=dp) :: temp_real
209 logical :: is_aqueous
210
211 is_aqueous = .false.
212
213 ! Get the property set
214 call assert_msg(852163263, associated(this%property_set), &
215 "Missing property set needed to initialize reaction")
216
217 ! Get the aerosol phase name
218 key_name = "aerosol phase"
219 call assert_msg(845445717, &
220 this%property_set%get_string(key_name, phase_name), &
221 "Missing aerosol phase in condensed-phase Photolysis reaction")
222
223 ! Get reactant species
224 key_name = "reactants"
225 call assert_msg(501773136, &
226 this%property_set%get_property_t(key_name, reactants), &
227 "Missing reactant species in condensed-phase Photolysis reaction")
228
229 ! Get product species
230 key_name = "products"
231 call assert_msg(556252922, &
232 this%property_set%get_property_t(key_name, products), &
233 "Missing product species in condensed-phase Photolysis reaction")
234
235 ! Count the number of species per phase instance (including reactants
236 ! with a "qty" specified)
237 call reactants%iter_reset()
238 num_react = 0
239 do while (reactants%get_key(spec_name))
240 ! Get properties included with this reactant in the reaction data
241 call assert(428593951, reactants%get_property_t(val=spec_props))
242 key_name = "qty"
243 if (spec_props%get_int(key_name, temp_int)) &
244 num_react = num_react + temp_int - 1
245 call reactants%iter_next()
246 num_react = num_react + 1
247 end do
248
249 ! Photolysis reactions only have 1 reactant, enforce that here
250 call assert_msg(890212987, num_react .eq. 1, &
251 "Too many species in condensed-phase Photolysis reaction. Only one reactant is expected.")
252
253 num_prod = products%size()
254 num_spec_per_phase = num_prod + num_react
255
256 ! Check for aerosol representations
257 call assert_msg(370755392, associated(aero_rep), &
258 "Missing aerosol representation for condensed-phase "// &
259 "Photolysis reaction")
260 call assert_msg(483073737, size(aero_rep).gt.0, &
261 "Missing aerosol representation for condensed-phase "// &
262 "Photolysis reaction")
263
264 ! Count the instances of the specified aerosol phase
265 num_phase = 0
266 do i_aero_rep = 1, size(aero_rep)
267 num_phase = num_phase + &
268 aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
269 end do
270
271 ! Allocate space in the condensed data arrays
272 allocate(this%condensed_data_int(num_int_prop_ + &
273 num_phase * (num_spec_per_phase * (num_react + 3) + 1)))
274 allocate(this%condensed_data_real(num_real_prop_ + &
275 num_spec_per_phase + num_prod))
276 this%condensed_data_int(:) = int(0, kind=i_kind)
277 this%condensed_data_real(:) = real(0.0, kind=dp)
278
279 ! Save space for the environment-dependent parameters
280 this%num_env_params = num_env_param_
281
282 ! Set the number of products, reactants and aerosol phase instances
283 num_react_ = num_react
284 num_prod_ = num_prod
285 num_aero_phase_ = num_phase
286
287 ! Get reaction parameters (it might be easiest to keep these at the
288 ! beginning of the condensed data array, so they can be accessed using
289 ! compliler flags)
290 key_name = "scaling factor"
291 if (.not. this%property_set%get_real(key_name, scaling_)) then
292 scaling_ = real(1.0, kind=dp)
293 end if
294
295 ! Set up an array to the reactant and product names
296 allocate(react_names(num_react_))
297 allocate(prod_names(num_prod_))
298
299 ! Get the chemical properties for the reactants
300 call reactants%iter_reset()
301 i_spec = 0
302 do while (reactants%get_key(spec_name))
303
304 ! Get the reactant species properties
305 call assert_msg(365229559, &
306 chem_spec_data%get_property_set(spec_name, spec_props), &
307 "Missing properties required for condensed-phase Photolysis "// &
308 "reaction involving species '"//trim(spec_name)//"'")
309
310 ! Get the molecular weight
311 key_name = "molecular weight [kg mol-1]"
312 call assert_msg(409180731, spec_props%get_real(key_name, temp_real), &
313 "Missing 'molecular weight' for species '"//trim(spec_name)// &
314 "' in condensed-phase Photolysis reaction.")
315
316 ! Set properties for each occurance of a reactant in the rxn equation
317 call assert(186449575, reactants%get_property_t(val=spec_props))
318 key_name = "qty"
319 if (.not.spec_props%get_int(key_name, temp_int)) temp_int = 1
320 do i_qty = 1, temp_int
321 i_spec = i_spec + 1
322
323 ! Add the reactant name to the list
324 react_names(i_spec)%string = spec_name
325
326 ! Use the MW to calculate the kg/m3 -> mol/m3 conversion
327 kgm3_to_molm3_(i_spec) = 1.0/temp_real
328
329 end do
330
331 ! Go to the next reactant
332 call reactants%iter_next()
333
334 end do
335
336 ! Get the chemical properties for the products
337 call products%iter_reset()
338 i_spec = 0
339 do while (products%get_key(spec_name))
340
341 ! Get the product species properties
342 call assert_msg(450225425, &
343 chem_spec_data%get_property_set(spec_name, spec_props), &
344 "Missing properties required for condensed-phase Photolysis "// &
345 "reaction involving species '"//trim(spec_name)//"'")
346
347 ! Increment the product counter
348 i_spec = i_spec + 1
349
350 ! Get the molecular weight
351 key_name = "molecular weight [kg mol-1]"
352 call assert_msg(504705211, spec_props%get_real(key_name, temp_real), &
353 "Missing 'molecular weight' for species '"//trim(spec_name)// &
354 "' in condensed phase Photolysis reaction.")
355
356 ! Use the MW to calculate the kg/m3 -> mol/m3 conversion
357 kgm3_to_molm3_(num_react_+i_spec) = 1.0/temp_real
358
359 ! Set properties for each occurance of a reactant in the rxn equation
360 call assert(846924553, products%get_property_t(val=spec_props))
361 key_name = "yield"
362 if (spec_props%get_real(key_name, temp_real)) then
363 yield_(i_spec) = temp_real
364 else
365 yield_(i_spec) = 1.0d0
366 end if
367
368 ! Add the product name to the list
369 prod_names(i_spec)%string = spec_name
370
371 ! Go to the next product
372 call products%iter_next()
373
374 end do
375
376 ! Get the units for the reactants and products and name for water
377 ! if this is an aqueous reaction
378 key_name = "units"
379 call assert_msg(348722817, &
380 this%property_set%get_string(key_name, temp_string), &
381 "Missing units for condensed-phase Photolysis reaction.")
382 if (trim(temp_string).eq."mol m-3") then
383 is_aqueous = .false.
384 key_name = "aerosol-phase water"
385 call assert_msg(767767240, &
386 .not.this%property_set%get_string(key_name, temp_string), &
387 "Aerosol-phase water specified for non-aqueous condensed-"// &
388 "phase Photolysis reaction. Change units to 'M' or remove "// &
389 "aerosol-phase water")
390 else if (trim(temp_string).eq."M") then
391 is_aqueous = .true.
392 key_name = "aerosol-phase water"
393 call assert_msg(199910264, &
394 this%property_set%get_string(key_name, water_name), &
395 "Missing aerosol-phase water for aqeuous condensed-phase "// &
396 "Photolysis reaction.")
397 else
398 call die_msg(161772048, "Received invalid units for condensed-"// &
399 "phase Photolysis reaction: '"//temp_string//"'. Valid "// &
400 "units are 'mol m-3' or 'M'.")
401 end if
402
403 ! Set the state array indices for the reactants, products and water
404 i_aero_phase = 0
405 do i_aero_rep = 1, size(aero_rep)
406
407 ! Check for the specified phase in this aero rep
408 num_phase = aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
409 if (num_phase.eq.0) cycle
410
411 ! Save the state ids for aerosol-phase water for aqueous reactions.
412 ! For non-aqueous reactions, set the water id to -1
413 if (is_aqueous) then
414
415 ! Get the unique names for aerosol-phase water
416 unique_names = aero_rep(i_aero_rep)%val%unique_names( &
417 phase_name = phase_name, spec_name = water_name)
418
419 ! Make sure water is present
420 call assert_msg(196838614, size(unique_names).eq.num_phase, &
421 "Missing aerosol-phase water species '"//water_name// &
422 "' in phase '"//phase_name//"' in aqueous condensed-"// &
423 "phase Photolysis reacion.")
424
425 ! Save the ids for water in this phase
426 do i_phase_inst = 1, num_phase
427 water_(i_aero_phase + i_phase_inst) = &
428 aero_rep(i_aero_rep)%val%spec_state_id( &
429 unique_names(i_phase_inst)%string)
430 end do
431
432 deallocate(unique_names)
433
434 else
435
436 ! Set the water ids to -1 for non-aqueous condensed-phase reactions
437 do i_phase_inst = 1, num_phase
438 water_(i_aero_phase + i_phase_inst) = -1
439 end do
440
441 end if
442
443 ! Loop through the reactants
444 do i_spec = 1, num_react_
445
446 ! Get the unique names for the reactants
447 unique_names = aero_rep(i_aero_rep)%val%unique_names( &
448 phase_name = phase_name, spec_name = react_names(i_spec)%string)
449
450 ! Make sure the right number of instances are present
451 call assert_msg(360730267, size(unique_names).eq.num_phase, &
452 "Incorrect instances of reactant '"// &
453 react_names(i_spec)%string//"' in phase '"//phase_name// &
454 "' in a condensed-phase Photolysis reaction")
455
456 ! Save the state ids for the reactant concentration
457 ! IDs are grouped by phase instance:
458 ! R1(phase1), R2(phase1), ..., R1(phase2)...
459 do i_phase_inst = 1, num_phase
460 react_((i_aero_phase+i_phase_inst-1)*num_react_ + i_spec) = &
461 aero_rep(i_aero_rep)%val%spec_state_id( &
462 unique_names(i_phase_inst)%string)
463 end do
464
465 deallocate(unique_names)
466
467 end do
468
469 ! Loop through the products
470 do i_spec = 1, num_prod_
471
472 ! Get the unique names for the products
473 unique_names = aero_rep(i_aero_rep)%val%unique_names( &
474 phase_name = phase_name, spec_name = prod_names(i_spec)%string)
475
476 ! Make sure the right number of instances are present
477 call assert_msg(399869427, size(unique_names).eq.num_phase, &
478 "Incorrect instances of product '"// &
479 prod_names(i_spec)%string//"' in phase '"//phase_name// &
480 "' in a condensed-phase Photolysis reaction")
481
482 ! Save the state ids for the product concentration
483 ! IDs are grouped by phase instance:
484 ! P1(phase1), P2(phase1), ..., P1(phase2)...
485 do i_phase_inst = 1, num_phase
486 prod_((i_aero_phase+i_phase_inst-1)*num_prod_ + i_spec) = &
487 aero_rep(i_aero_rep)%val%spec_state_id( &
488 unique_names(i_phase_inst)%string)
489 end do
490
491 deallocate(unique_names)
492
493 end do
494
495 ! Increment the index offset for the next aerosol representation
496 i_aero_phase = i_aero_phase + num_phase
497
498 end do
499
500 ! Initialize the reaction id
501 rxn_id_ = -1
502
503 end subroutine initialize
504
505!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
506
507 !> Get the reaction properties. (For use by external photolysis modules.)
508 function get_property_set(this) result(prop_set)
509
510 !> Reaction properties
511 type(property_t), pointer :: prop_set
512 !> Reaction data
513 class(rxn_condensed_phase_photolysis_t), intent(in) :: this
514
515 prop_set => this%property_set
516
517 end function get_property_set
518
519!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
520
521 !> Finalize the reaction
522 elemental subroutine finalize(this)
523
524 !> Reaction data
525 type(rxn_condensed_phase_photolysis_t), intent(inout) :: this
526
527 if (associated(this%property_set)) &
528 deallocate(this%property_set)
529 if (allocated(this%condensed_data_real)) &
530 deallocate(this%condensed_data_real)
531 if (allocated(this%condensed_data_int)) &
532 deallocate(this%condensed_data_int)
533
534 end subroutine finalize
535
536!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
537
538 !> Set packed update data for photolysis rate constants
539 subroutine update_data_rate_set(this, base_rate)
540
541 !> Update data
542 class(rxn_update_data_condensed_phase_photolysis_t), intent(inout) :: this
543 !> Updated pre-scaling photolysis rate
544 real(kind=dp), intent(in) :: base_rate
545
547 this%rxn_unique_id, base_rate)
548
549 end subroutine update_data_rate_set
550
551!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
552
553 !> Initialize update data
554 subroutine update_data_initialize(this, update_data, rxn_type)
555
556 use camp_rand, only : generate_int_id
557
558 !> The reaction to update
559 class(rxn_condensed_phase_photolysis_t), intent(inout) :: this
560 !> Update data object
561 class(rxn_update_data_condensed_phase_photolysis_t), intent(out) :: update_data
562 !> Reaction type id
563 integer(kind=i_kind), intent(in) :: rxn_type
564
565 ! If a reaction id has not yet been generated, do it now
566 if (rxn_id_.eq.-1) then
567 rxn_id_ = generate_int_id()
568 endif
569
570 update_data%rxn_unique_id = rxn_id_
571 update_data%rxn_type = int(rxn_type, kind=c_int)
573 update_data%is_malloced = .true.
574
575 end subroutine update_data_initialize
576
577!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
578
579 !> Determine the size of a binary required to pack the reaction data
580 integer(kind=i_kind) function internal_pack_size(this, comm) &
581 result(pack_size)
582
583 !> Reaction update data
584 class(rxn_update_data_condensed_phase_photolysis_t), intent(in) :: this
585 !> MPI communicator
586 integer, intent(in) :: comm
587
588 pack_size = &
589 camp_mpi_pack_size_logical(this%is_malloced, comm) + &
590 camp_mpi_pack_size_integer(this%rxn_unique_id, comm)
591
592 end function internal_pack_size
593
594!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
595
596 !> Pack the given value to the buffer, advancing position
597 subroutine internal_bin_pack(this, buffer, pos, comm)
598
599 !> Reaction update data
600 class(rxn_update_data_condensed_phase_photolysis_t), intent(in) :: this
601 !> Memory buffer
602 character, intent(inout) :: buffer(:)
603 !> Current buffer position
604 integer, intent(inout) :: pos
605 !> MPI communicator
606 integer, intent(in) :: comm
607
608#ifdef CAMP_USE_MPI
609 integer :: prev_position
610
611 prev_position = pos
612 call camp_mpi_pack_logical(buffer, pos, this%is_malloced, comm)
613 call camp_mpi_pack_integer(buffer, pos, this%rxn_unique_id, comm)
614 call assert(649543400, &
615 pos - prev_position <= this%pack_size(comm))
616#endif
617
618 end subroutine internal_bin_pack
619
620!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
621
622 !> Unpack the given value from the buffer, advancing position
623 subroutine internal_bin_unpack(this, buffer, pos, comm)
624
625 !> Reaction update data
626 class(rxn_update_data_condensed_phase_photolysis_t), intent(inout) :: this
627 !> Memory buffer
628 character, intent(inout) :: buffer(:)
629 !> Current buffer position
630 integer, intent(inout) :: pos
631 !> MPI communicator
632 integer, intent(in) :: comm
633
634#ifdef CAMP_USE_MPI
635 integer :: prev_position
636
637 prev_position = pos
638 call camp_mpi_unpack_logical(buffer, pos, this%is_malloced, comm)
639 call camp_mpi_unpack_integer(buffer, pos, this%rxn_unique_id, comm)
640 call assert(254749806, &
641 pos - prev_position <= this%pack_size(comm))
643#endif
644
645 end subroutine internal_bin_unpack
646
647!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
648
649 !> Finalize an update data object
650 elemental subroutine update_data_finalize(this)
651
652 !> Update data object to free
653 type(rxn_update_data_condensed_phase_photolysis_t), intent(inout) :: this
654
655 if (this%is_malloced) call rxn_free_update_data(this%update_data)
656
657 end subroutine update_data_finalize
658
659!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
660
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.
elemental subroutine finalize(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.
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.
elemental subroutine update_data_finalize(this)
Finalize an update data object.
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.
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:88
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 to aero_rep_data_t extending types.
Abstract reaction data type.
Definition rxn_data.F90:98
String type for building arrays of string of various size.
Definition util.F90:38