64 integer(kind=i_kind) :: num_rxn = 0
66 character(len=:),
allocatable :: mech_name
68 character(len=:),
allocatable :: fixed_file_prefix
101 procedure :: constructor
124 character(len=*),
intent(in),
optional :: mech_name
126 integer(i_kind),
intent(in),
optional :: init_size
128 integer(i_kind) :: alloc_size
133 if (
present(init_size)) alloc_size = init_size
134 if (
present(mech_name))
then
135 new_obj%mech_name = mech_name
137 new_obj%mech_name =
""
139 allocate(new_obj%rxn_ptr(alloc_size))
152 integer(i_kind),
intent(in) :: num_rxn
154 integer(kind=i_kind) :: new_size
157 if (
size(this%rxn_ptr) .ge. this%num_rxn + num_rxn)
return
159 allocate(new_rxn_ptr(new_size))
160 new_rxn_ptr(1:this%num_rxn) = this%rxn_ptr(1:this%num_rxn)
161 call this%rxn_ptr(:)%dereference()
162 deallocate(this%rxn_ptr)
163 this%rxn_ptr => new_rxn_ptr
194 subroutine load(this, json, j_obj)
199 type(json_core),
pointer,
intent(in) :: json
201 type(json_value),
pointer,
intent(in) :: j_obj
203 type(json_value),
pointer :: child, next
204 character(kind=json_ck, len=:),
allocatable :: unicode_str_val
212 call json%get(j_obj,
'reactions(1)', child, found)
213 do while (
associated(child) .and. found)
216 call this%ensure_size(1)
217 this%num_rxn = this%num_rxn + 1
220 this%rxn_ptr(this%num_rxn)%val => rxn_factory%load(json, child)
223 call json%get_next(child, next)
228 call json%get(j_obj,
'build fixed module', unicode_str_val, found)
230 call assert_msg(410823202, .not.
allocated(this%fixed_file_prefix), &
231 "Received multiple file prefixes for fixed mechanism module.")
232 this%fixed_file_prefix = trim(unicode_str_val)
236 subroutine load(this)
241 call warn_msg(384838139,
"No support for input files")
249 subroutine initialize(this, chem_spec_data, aero_phase_data, aero_rep_data, &
261 integer(kind=i_kind),
intent(in) :: n_cells
263 integer(kind=i_kind) :: i_rxn
265 do i_rxn = 1, this%num_rxn
266 call assert(340397127,
associated(this%rxn_ptr(i_rxn)%val))
267 call this%rxn_ptr(i_rxn)%val%initialize(chem_spec_data, aero_phase_data, &
268 aero_rep_data, n_cells)
288 function get_rxn(this, rxn_id)
result (rxn_ptr)
295 integer(kind=i_kind),
intent(in) :: rxn_id
297 call assert_msg(129484547, rxn_id.gt.0 .and. rxn_id .le. this%num_rxn, &
298 "Invalid reaction id: "//trim(
to_string(rxn_id))//&
299 "exptected a value between 1 and "//trim(
to_string(this%num_rxn)))
301 rxn_ptr => this%rxn_ptr(rxn_id)%val
311 character(len=:),
allocatable :: mech_name
315 mech_name = this%mech_name
327 integer,
intent(in) :: comm
330 integer(kind=i_kind) :: i_rxn
333 do i_rxn = 1, this%num_rxn
348 character,
intent(inout) :: buffer(:)
350 integer,
intent(inout) :: pos
352 integer,
intent(in) :: comm
356 integer :: i_rxn, prev_position
360 do i_rxn = 1, this%num_rxn
361 associate(rxn => this%rxn_ptr(i_rxn)%val)
362 call rxn_factory%bin_pack(rxn, buffer, pos, comm)
366 pos - prev_position <= this%pack_size(comm))
379 character,
intent(inout) :: buffer(:)
381 integer,
intent(inout) :: pos
383 integer,
intent(in) :: comm
387 integer :: i_rxn, prev_position, num_rxn
391 call this%ensure_size(num_rxn)
392 this%num_rxn = num_rxn
393 do i_rxn = 1, this%num_rxn
394 this%rxn_ptr(i_rxn)%val => rxn_factory%bin_unpack(buffer, pos, comm)
397 pos - prev_position <= this%pack_size(comm))
410 integer(kind=i_kind),
optional :: file_unit
413 integer(kind=i_kind) :: f_unit
417 if (
present(file_unit)) f_unit = file_unit
419 write(f_unit,*)
"Mechanism: "//trim(this%name())
420 do i_rxn = 1, this%num_rxn
421 call this%rxn_ptr(i_rxn)%val%print(f_unit)
423 write(f_unit,*)
"End mechanism: "//trim(this%name())
435 if (
allocated(this%mech_name))
deallocate(this%mech_name)
436 if (
allocated(this%fixed_file_prefix))
deallocate(this%fixed_file_prefix)
437 if (
associated(this%rxn_ptr))
deallocate(this%rxn_ptr)
449 integer(kind=i_kind) :: i_mech
451 do i_mech = 1,
size(this)
477 if (
associated(this%val))
deallocate(this%val)
489 integer(kind=i_kind) :: i_mech
491 do i_mech = 1,
size(this)
Get the size of the section of the camp_camp_state::camp_state_t::state_var array required for this a...
Initialize the aerosol representation data, validating component data and loading any required inform...
Interface for to_string functions.
The abstract aero_phase_data_t structure and associated subroutines.
integer(kind=i_kind), parameter realloc_inc
Reallocation increment.
subroutine finalize_array(this)
Finalize the aerosol phase data.
subroutine bin_unpack(this, buffer, pos, comm)
Unpack the given value from the buffer, advancing position.
character(len=:) function, allocatable get_name(this)
Get the aerosol phase name.
type(aero_phase_data_t) function, pointer constructor(phase_name, init_size)
Constructor for aero_phase_data_t.
subroutine ptr_finalize_array(this)
Finalize an array of pointers to aerosol phase data.
subroutine bin_pack(this, buffer, pos, comm)
Pack the given value to the buffer, advancing position.
subroutine load(this, json, j_obj)
Load species from an input file.
subroutine ensure_size(this, num_spec)
Ensure there is enough room in the species dataset to add a specified number of species.
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.
subroutine ptr_finalize(this)
Finalize a pointer to aerosol phase data.
subroutine do_print(this, file_unit)
Print out the aerosol phase data.
elemental subroutine dereference(this)
Dereference a pointer to 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.
integer, parameter i_kind
Kind of an integer.
The mechanism_data_t structure and associated subroutines.
integer(kind=i_kind), parameter mech_file_unit
Fixed module file unit.
class(rxn_data_t) function, pointer get_rxn(this, rxn_id)
Get a reaction by its index.
Wrapper functions for MPI.
subroutine camp_mpi_unpack_integer(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
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 rxn_data_t structure and associated subroutines.
The abstract rxn_factory_t structure and associated subroutines.
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.
subroutine warn_msg(code, warning_msg, already_warned)
Prints a warning message.
Pointer type for building arrays.
Pointer to aero_rep_data_t extending types.
Pointer type for building arrays.
Pointer type for building arrays of mixed reactions.
Abstract reaction data type.
Factory type for chemical reactions.
String type for building arrays of string of various size.