24 integer(kind=i_kind) :: idx_o3, idx_no, idx_no2, idx_o2
27 character(len=*),
parameter :: fmt_hdr =
"(A10,',',A10,',',A10,',',A10,',',A10)"
28 character(len=*),
parameter :: fmt_dat =
"(ES10.4,',',ES10.4,',',ES10.4,',',ES10.4,',',ES10.4)"
30 integer(kind=i_kind) :: i_time
32 integer(kind=i_kind) :: i_rxn
33 character(len=:),
allocatable :: photo_label
42 character,
allocatable :: buffer(:)
54 call camp_core%initialize( )
57 if( .not.camp_core%get_chem_spec_data( chem_spec_data ) )
then
58 write(*,*)
"Something's gone wrong!"
62 idx_o3 = chem_spec_data%gas_state_id(
"O3" )
63 idx_no = chem_spec_data%gas_state_id(
"NO" )
64 idx_no2 = chem_spec_data%gas_state_id(
"NO2" )
65 idx_o2 = chem_spec_data%gas_state_id(
"O2" )
66 if( idx_o3.eq.0 .or. idx_no2.eq.0 .or.idx_o2.eq.0 )
then
67 write(*,*)
"Missing species!"
71 if( .not.camp_core%get_mechanism(
"my simple mechanism", mechanism ) )
then
72 write(*,*)
"Missing mechanism!"
76 do i_rxn = 1, mechanism%size( )
77 photo_rxn => mechanism%get_rxn( i_rxn )
78 select type( photo_rxn )
80 if( photo_rxn%property_set%get_string(
"my photo label", photo_label ) )
then
81 if( photo_label .eq.
"NO2 photolysis" )
then
82 call camp_core%initialize_update_object( photo_rxn, no2_photolysis )
92 no2_photolysis%pack_size( )
98 call camp_core%bin_pack( buffer, pos )
99 call no2_photolysis%bin_pack( buffer, pos )
126 call camp_core%bin_unpack( buffer, pos )
127 call no2_photolysis%bin_unpack( buffer, pos )
135 call camp_core%solver_initialize( )
136 camp_state => camp_core%new_state( )
138 call camp_state%env_states(1)%set_temperature_K( 275.4_dp )
139 call camp_state%env_states(1)%set_pressure_Pa( 101532.2_dp )
141 camp_state%state_var( idx_o3 ) = 0.13
142 camp_state%state_var( idx_no ) = 0.02
143 camp_state%state_var( idx_no2 ) = 0.053
144 camp_state%state_var( idx_o2 ) = 2.1e5
147 call no2_photolysis%set_rate( 12.2d0 )
148 call camp_core%update_data( no2_photolysis )
156 write(*,fmt_hdr)
"time",
"O3",
"NO",
"NO2",
"O2"
158 call camp_core%solve( camp_state, 1.0d-15 )
159 write(*,fmt_dat) i_time*1.0e-15, &
160 camp_state%state_var( idx_o3 ), &
161 camp_state%state_var( idx_no ), &
162 camp_state%state_var( idx_no2 ), &
163 camp_state%state_var( idx_o2 )
173 deallocate( camp_core )
174 deallocate( camp_state )
The camp_core_t structure and associated subroutines.
integer(kind=i_kind) function pack_size(this, comm)
Determine the size of a binary required to pack the mechanism.
The camp_state_t structure and associated subroutines.
The chem_spec_data_t structure and associated subroutines.
The mechanism_data_t structure and associated subroutines.
Wrapper functions for MPI.
subroutine camp_mpi_init()
Initialize MPI.
integer function camp_mpi_rank(comm)
Returns the rank of the current process.
subroutine camp_mpi_bcast_packed(val, comm)
Broadcast the given value from process 0 to all other processes.
subroutine camp_mpi_finalize()
Shut down MPI.
subroutine camp_mpi_bcast_integer(val, comm)
Broadcast the given value from process 0 to all other processes.
The rxn_data_t structure and associated subroutines.
The abstract rxn_factory_t structure and associated subroutines.
The rxn_photolysis_t type and associated functions.
Abstract reaction data type.
Factory type for chemical reactions.
Generic test reaction data type.
Photolysis rate update object.