63 integer(kind=i_kind) :: num_rxn = 0
65 character(len=:),
allocatable :: mech_name
67 character(len=:),
allocatable :: fixed_file_prefix
123 character(len=*),
intent(in),
optional :: mech_name
125 integer(i_kind),
intent(in),
optional :: init_size
127 integer(i_kind) :: alloc_size
132 if (
present(init_size)) alloc_size = init_size
133 if (
present(mech_name))
then
134 new_obj%mech_name = mech_name
136 new_obj%mech_name =
""
138 allocate(new_obj%rxn_ptr(alloc_size))
151 integer(i_kind),
intent(in) :: num_rxn
153 integer(kind=i_kind) :: new_size
156 if (
size(this%rxn_ptr) .ge. this%num_rxn + num_rxn)
return
158 allocate(new_rxn_ptr(new_size))
159 new_rxn_ptr(1:this%num_rxn) = this%rxn_ptr(1:this%num_rxn)
160 call this%rxn_ptr(:)%dereference()
161 deallocate(this%rxn_ptr)
162 this%rxn_ptr => new_rxn_ptr
193 subroutine load(this, json, j_obj)
198 type(json_core),
pointer,
intent(in) :: json
200 type(json_value),
pointer,
intent(in) :: j_obj
202 type(json_value),
pointer :: child, next
203 character(kind=json_ck, len=:),
allocatable :: unicode_str_val
211 call json%get(j_obj,
'reactions(1)', child, found)
212 do while (
associated(child) .and. found)
215 call this%ensure_size(1)
216 this%num_rxn = this%num_rxn + 1
219 this%rxn_ptr(this%num_rxn)%val => rxn_factory%load(json, child)
222 call json%get_next(child, next)
227 call json%get(j_obj,
'build fixed module', unicode_str_val, found)
229 call assert_msg(410823202, .not.
allocated(this%fixed_file_prefix), &
230 "Received multiple file prefixes for fixed mechanism module.")
231 this%fixed_file_prefix = trim(unicode_str_val)
235 subroutine load(this)
240 call warn_msg(384838139,
"No support for input files")
248 subroutine initialize(this, chem_spec_data, aero_rep_data, n_cells)
257 integer(kind=i_kind),
intent(in) :: n_cells
259 integer(kind=i_kind) :: i_rxn
261 do i_rxn = 1, this%num_rxn
262 call assert(340397127,
associated(this%rxn_ptr(i_rxn)%val))
263 call this%rxn_ptr(i_rxn)%val%initialize(chem_spec_data, aero_rep_data, &
284 function get_rxn(this, rxn_id)
result (rxn_ptr)
291 integer(kind=i_kind),
intent(in) :: rxn_id
293 call assert_msg(129484547, rxn_id.gt.0 .and. rxn_id .le. this%num_rxn, &
294 "Invalid reaction id: "//trim(
to_string(rxn_id))//&
295 "exptected a value between 1 and "//trim(
to_string(this%num_rxn)))
297 rxn_ptr => this%rxn_ptr(rxn_id)%val
307 character(len=:),
allocatable :: mech_name
311 mech_name = this%mech_name
323 integer,
intent(in) :: comm
326 integer(kind=i_kind) :: i_rxn
329 do i_rxn = 1, this%num_rxn
344 character,
intent(inout) :: buffer(:)
346 integer,
intent(inout) :: pos
348 integer,
intent(in) :: comm
352 integer :: i_rxn, prev_position
356 do i_rxn = 1, this%num_rxn
357 associate(rxn => this%rxn_ptr(i_rxn)%val)
358 call rxn_factory%bin_pack(rxn, buffer, pos, comm)
362 pos - prev_position <= this%pack_size(comm))
375 character,
intent(inout) :: buffer(:)
377 integer,
intent(inout) :: pos
379 integer,
intent(in) :: comm
383 integer :: i_rxn, prev_position, num_rxn
387 call this%ensure_size(num_rxn)
388 this%num_rxn = num_rxn
389 do i_rxn = 1, this%num_rxn
390 this%rxn_ptr(i_rxn)%val => rxn_factory%bin_unpack(buffer, pos, comm)
393 pos - prev_position <= this%pack_size(comm))
406 integer(kind=i_kind),
optional :: file_unit
409 integer(kind=i_kind) :: f_unit
413 if (
present(file_unit)) f_unit = file_unit
415 write(f_unit,*)
"Mechanism: "//trim(this%name())
416 do i_rxn = 1, this%num_rxn
417 call this%rxn_ptr(i_rxn)%val%print(f_unit)
419 write(f_unit,*)
"End mechanism: "//trim(this%name())
431 if (
allocated(this%mech_name))
deallocate(this%mech_name)
432 if (
allocated(this%fixed_file_prefix))
deallocate(this%fixed_file_prefix)
433 if (
associated(this%rxn_ptr))
deallocate(this%rxn_ptr)
457 if (
associated(this%val))
deallocate(this%val)
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_rep_data_t structure and associated subroutines.
subroutine do_print(this, file_unit)
Print the aerosol representation data.
integer(kind=i_kind) function pack_size(this, comm)
Determine the size of a binary required to pack the aerosol representation data.
subroutine load(this, json, j_obj)
Load an aerosol representation from an input file.
subroutine bin_unpack(this, buffer, pos, comm)
Unpack the given value from the buffer, advancing position.
elemental subroutine dereference(this)
Deference a pointer to an aerosol representation.
subroutine bin_pack(this, buffer, pos, comm)
Pack the given value to the buffer, advancing position.
elemental subroutine ptr_finalize(this)
Finalize a pointer to an aerosol representation.
character(len=:) function, allocatable get_name(this)
Get the name of the aerosol representation.
The camp_state_t structure and associated subroutines.
elemental subroutine finalize(this)
Finalize the state.
The chem_spec_data_t structure and associated subroutines.
integer(kind=i_kind), parameter realloc_inc
Reallocation increment.
subroutine ensure_size(this, num_spec)
Ensure there is enough room in the species dataset to add a specified number of species.
type(chem_spec_data_t) function, pointer constructor(init_size)
Constructor for chem_spec_data_t.
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 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.