PartMC  2.3.0
run_exact.F90
Go to the documentation of this file.
1 ! Copyright (C) 2005-2012 Nicole Riemer and Matthew West
2 ! Licensed under the GNU General Public License version 2 or (at your
3 ! option) any later version. See the file COPYING for details.
4 
5 !> \file
6 !> The pmc_run_exact module.
7 
8 !> Exact solution simulation.
10 
11  use pmc_aero_dist
12  use pmc_bin_grid
13  use pmc_aero_state
14  use pmc_scenario
15  use pmc_env_state
16  use pmc_aero_data
17  use pmc_output
18  use pmc_aero_binned
19  use pmc_gas_data
20  use pmc_gas_state
21  use pmc_exact_soln
22 
23  !> Options controlling the execution of run_exact().
25  !> Total simulation time.
26  real(kind=dp) :: t_max
27  !> Interval to output info (s).
28  real(kind=dp) :: t_output
29  !> Output prefix.
30  character(len=300) :: prefix
31  !> Whether to do coagulation.
32  logical :: do_coagulation
33  !> Type of coagulation kernel.
34  integer :: coag_kernel_type
35  !> Whether to do particle loss.
36  logical :: do_loss
37  !> Type of loss rate function.
38  integer :: loss_function_type
39  !> UUID of the simulation.
40  character(len=PMC_UUID_LEN) :: uuid
41  end type run_exact_opt_t
42 
43 contains
44 
45 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46 
47  !> Run an exact simulation.
48  subroutine run_exact(bin_grid, scenario, env_state, aero_data, &
49  aero_dist_init, run_exact_opt)
50 
51  !> Bin grid.
52  type(bin_grid_t), intent(in) :: bin_grid
53  !> Environment data.
54  type(scenario_t), intent(in) :: scenario
55  !> Environment state.
56  type(env_state_t), intent(inout) :: env_state
57  !> Aerosol data.
58  type(aero_data_t), intent(in) :: aero_data
59  !> Initial aerosol distribution.
60  type(aero_dist_t), intent(in) :: aero_dist_init
61  !> Options.
62  type(run_exact_opt_t), intent(in) :: run_exact_opt
63 
64  integer :: i_time, n_time, ncid
65  type(aero_binned_t) :: aero_binned
66  real(kind=dp) :: time
67  type(gas_data_t) :: gas_data
68  type(gas_state_t) :: gas_state
69 
70  call check_time_multiple("t_max", run_exact_opt%t_max, &
71  "t_output", run_exact_opt%t_output)
72 
73  call aero_binned_allocate_size(aero_binned, bin_grid%n_bin, &
74  aero_data%n_spec)
75  call gas_data_allocate(gas_data)
76  call gas_state_allocate(gas_state)
77 
78  n_time = nint(run_exact_opt%t_max / run_exact_opt%t_output)
79  do i_time = 0,n_time
80  time = real(i_time, kind=dp) / real(n_time, kind=dp) &
81  * run_exact_opt%t_max
82  call scenario_update_env_state(scenario, env_state, time)
83  call exact_soln(bin_grid, aero_data, run_exact_opt%do_coagulation, &
84  run_exact_opt%coag_kernel_type, run_exact_opt%do_loss, &
85  run_exact_opt%loss_function_type, aero_dist_init, scenario, &
86  env_state, time, aero_binned)
87  call output_sectional(run_exact_opt%prefix, bin_grid, aero_data, &
88  aero_binned, gas_data, gas_state, env_state, i_time + 1, &
89  time, run_exact_opt%t_output, run_exact_opt%uuid)
90  end do
91 
92  call gas_data_deallocate(gas_data)
93  call gas_state_deallocate(gas_state)
94  call aero_binned_deallocate(aero_binned)
95 
96  end subroutine run_exact
97 
98 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
99 
100 end module pmc_run_exact
subroutine aero_binned_allocate_size(aero_binned, n_bin, n_spec)
Allocate an aero_binned_t of the given size.
Definition: aero_binned.F90:60
The scenario_t structure and associated subroutines.
Definition: scenario.F90:9
The aero_data_t structure and associated subroutines.
Definition: aero_data.F90:9
Exact solutions for various simulations.
Definition: exact_soln.F90:9
Options controlling the execution of run_exact().
Definition: run_exact.F90:24
The aero_dist_t structure and associated subroutines.
Definition: aero_dist.F90:18
The env_state_t structure and associated subroutines.
Definition: env_state.F90:9
subroutine aero_binned_deallocate(aero_binned)
Free internal memory in an aero_binned_t structure.
Definition: aero_binned.F90:79
subroutine scenario_update_env_state(scenario, env_state, time)
Update time-dependent contents of the environment. scenario_init_env_state() should have been called ...
Definition: scenario.F90:301
subroutine exact_soln(bin_grid, aero_data, do_coagulation, coag_kernel_type, do_loss, loss_function_type, aero_dist_init, scenario, env_state, time, aero_binned)
Definition: exact_soln.F90:28
subroutine gas_data_deallocate(gas_data)
Free all storage.
Definition: gas_data.F90:75
The gas_data_t structure and associated subroutines.
Definition: gas_data.F90:9
subroutine check_time_multiple(first_name, first_time, second_name, second_time)
Check that the first time interval is close to an integer multiple of the second, and warn if it is n...
Definition: util.F90:368
A complete aerosol distribution, consisting of several modes.
Definition: aero_dist.F90:33
Current environment state.
Definition: env_state.F90:26
The aero_state_t structure and assocated subroutines.
Definition: aero_state.F90:9
subroutine gas_state_deallocate(gas_state)
Free all storage.
Definition: gas_state.F90:63
The gas_state_t structure and associated subroutines.
Definition: gas_state.F90:9
subroutine gas_state_allocate(gas_state)
Allocate storage for gas species.
Definition: gas_state.F90:36
Scenario data.
Definition: scenario.F90:51
1D grid, either logarithmic or linear.
Definition: bin_grid.F90:33
Exact solution simulation.
Definition: run_exact.F90:9
The bin_grid_t structure and associated subroutines.
Definition: bin_grid.F90:9
The aero_binned_t structure and associated subroutines.
Definition: aero_binned.F90:9
subroutine gas_data_allocate(gas_data)
Allocate storage for gas species.
Definition: gas_data.F90:45
Current state of the gas mixing ratios in the system.
Definition: gas_state.F90:26
Constant gas data.
Definition: gas_data.F90:29
Aerosol material properties and associated data.
Definition: aero_data.F90:40
subroutine run_exact(bin_grid, scenario, env_state, aero_data, aero_dist_init, run_exact_opt)
Run an exact simulation.
Definition: run_exact.F90:48
Write data in NetCDF format.
Definition: output.F90:68
Aerosol number and volume distributions stored per bin.
Definition: aero_binned.F90:33
subroutine output_sectional(prefix, bin_grid, aero_data, aero_binned, gas_data, gas_state, env_state, index, time, del_t, uuid)
Write the current sectional data.
Definition: output.F90:676