PartMC  2.9.0
partmc.F90
Go to the documentation of this file.
1 ! Copyright (C) 2007-2012, 2016, 2017, 2018, 2021 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 partmc program.
7 
8 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9 
10 !> \mainpage PartMC Code Documentation
11 !!
12 !! \subpage input_format - Input file format description.
13 !!
14 !! \subpage output_format - Output file format description.
15 !!
16 !! \subpage module_diagram - Diagram of modules and dependencies.
17 !!
18 !! \subpage coding_style - Description of code conventions and style.
19 !!
20 !! \subpage publications - Publications about PartMC.
21 
22 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23 
24 !> \page input_format Input File Format
25 !!
26 !! The input file format is plain text:
27 !!
28 !! \subpage spec_file_format "Spec File Format"
29 !!
30 !! When running PartMC with the command <tt>partmc input.spec</tt> the
31 !! first line of the <tt>input.spec</tt> file must define the \c
32 !! run_type with:
33 !! <pre>
34 !! run_type &lt;type&gt;
35 !! </pre>
36 !! where <tt>&lt;type&gt;</tt> is one of \c particle, \c exact, \c
37 !! sectional, or \c modal. This determines the type of run as well as
38 !! the format of the remainder of the spec file. The rest of the spec
39 !! file is described by:
40 !!
41 !! \subpage input_format_particle "Particle-resolved simulation"
42 !!
43 !! \subpage input_format_exact "Exact (analytical) solution"
44 !!
45 !! \subpage input_format_sectional "Sectional model simulation"
46 !!
47 !! \subpage input_format_modal "Modal aerosol simulation"
48 
49 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
50 
51 !> \page module_diagram Module Diagram
52 !!
53 !! \dotfile partmc_modules.gv
54 
55 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
56 
57 !> \page coding_style Coding Style
58 !!
59 !! The code is mainly modern Fortran, with a few parts still clearly
60 !! showing their Fortran 77 heritage. Fortran 2003 features are used
61 !! heavily (especially allocatable array features). The code needs to
62 !! be processed with \c cpp or a compatible pre-processor.
63 !!
64 !! \section oo_fortran Object Oriented Fortran
65 !!
66 !! Extensive use is made of Fortran 90 derived types. Derived types
67 !! are named \c my_type_t and are generally defined in modules named
68 !! \c pmc_my_type within files named \c my_type.F90. Almost all
69 !! subroutines and function in each \c my_type.F90 file have names of
70 !! the form \c my_type_*() and take an object of type \c my_type_t
71 !! (called \c my_type) as the first argument on which to operate.
72 !!
73 !! Module names are always the same as the name of the containing
74 !! file, but prefixed with \c pmc_. Thus the module \c
75 !! pmc_condense is contained in the file \c condense.F90.
76 !!
77 !! \section mem_manage Memory Management
78 !!
79 !! The memory allocation policy is to always use \c allocatable
80 !! arrays and to do the allocation in the lowest-level routine
81 !! possible. Explicit \c allocate() and \c deallocate() statements are
82 !! discouraged in favor of automatic memory management, where
83 !! possible.
84 
85 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86 
87 !> \page publications PartMC Publications
88 !!
89 !! - Z.&nbsp;Zheng, J.&nbsp;H. Curtis, Y. Yao, J.&nbsp;T. Gasparik,
90 !! V.&nbsp;G. Anantharaj, L. Zhao, M. West, and N. Riemer (2021)
91 !! Estimating submicron aerosol mixing state at the global scale
92 !! with machine learning and earth system modeling, <i>Earth and
93 !! Space Science</i> <b>8</b>(2), e2020EA001500, DOI: <a
94 !! href="http://dx.doi.org/10.1029/2020EA001500">10.1029/2020EA001500</a>.
95 !! - J.&nbsp;T. Gasparik, Q. Ye, J.&nbsp;H. Curtis,
96 !! A.&nbsp;A. Presto, N.&nbsp;M. Donahue, R.&nbsp;C. Sullivan,
97 !! M. West, and N. Riemer (2020) Quantifying errors in the aerosol
98 !! mixing-state index based on limited particle sample size,
99 !! <i>Aerosol Science and Technology</i> <b>54</b>(12), 1527-1541,
100 !! DOI: <a
101 !! href="http://dx.doi.org/10.1080/02786826.2020.1804523">10.1080/02786826.2020.1804523</a>.
102 !! - C. Shou, N. Riemer, T.&nbsp;B. Onasch, A.&nbsp;J. Sedlacek,
103 !! A.&nbsp;T. Lambe, E.&nbsp;R. Lewis, P. Davidovits, and M. West
104 !! (2019) Mixing state evolution of agglomerating particles in an
105 !! aerosol chamber: Comparison of measurements and
106 !! particle-resolved simulations, <i>Aerosol Science and
107 !! Technology</i> <b>53</b>(11), 1229-1243, DOI: <a
108 !! href="http://dx.doi.org/10.1080/02786826.2019.1661959">10.1080/02786826.2019.1661959</a>
109 !! - N. Riemer, A.&nbsp;P. Ault, M. West, R.&nbsp;L. Craig, and
110 !! J.&nbsp;H. Curtis (2019) Aerosol mixing state: Measurements,
111 !! modeling, and impacts, <i>Reviews of Geophysics</i>
112 !! <b>57</b>(2), 187-249, DOI: <a
113 !! href="http://dx.doi.org/10.1029/2018RG000615">10.1029/2018RG000615</a>
114 !! - R.&nbsp;E.&nbsp;L. DeVille, N. Riemer, and M. West (2019)
115 !! Convergence of a generalized Weighted Flow Algorithm for
116 !! stochastic particle coagulation, <i>Journal of Computational
117 !! Dynamics</i> <b>6</b>(1), 69-94, DOI: <a
118 !! href="http://dx.doi.org/10.3934/jcd.2019003">10.3934/jcd.2019003</a>
119 !! - M.&nbsp;Hughes, J.&nbsp;K.&nbsp;Kodros, J.&nbsp;R.&nbsp;Pierce,
120 !! M.&nbsp;West, and N.&nbsp;Riemer (2018) Machine learning to
121 !! predict the global distribution of aerosol mixing state
122 !! metrics, <i>Atmosphere</i> <b>9</b>(1), 15, DOI: <a
123 !! href="http://dx.doi.org/10.3390/atmos9010015">10.3390/atmos9010015</a>.
124 !! - J.&nbsp;Ching, M.&nbsp;West, and N.&nbsp;Riemer (2018)
125 !! Quantifying impacts of aerosol mixing state on
126 !! nucleation-scavenging of black carbon aerosol particles,
127 !! <i>Atmosphere</i> <b>9</b>(1), 17, DOI: <a
128 !! href="http://dx.doi.org/10.3390/atmos9010017">10.3390/atmos9010017</a>.
129 !! - J.&nbsp;H.&nbsp;Curtis, N.&nbsp;Riemer, and M.&nbsp;West,
130 !! (2017) A single-column particle-resolved model for simulating
131 !! the vertical distribution of aerosol mixing state:
132 !! WRF-PartMC-MOSAIC-SCM v1.0, <i>Geoscientific Model
133 !! Development</i> <b>10</b>, 4057-4079, DOI: <a
134 !! href="http://dx.doi.org/10.5194/gmd-10-4057-2017">10.5194/gmd-10-4057-2017</a>.
135 !! - J.&nbsp;Tian, B.&nbsp;T.&nbsp;Brem, M.&nbsp;West,
136 !! T.&nbsp;C.&nbsp;Bond, M.&nbsp;J.&nbsp;Rood, and N.&nbsp;Riemer
137 !! (2017) Simulating aerosol chamber experiments with the
138 !! particle-resolved aerosol model PartMC, <i>Aerosol Science and
139 !! Technology</i> <b>51</b>(7), 856-867, DOI: <a
140 !! href="http://dx.doi.org/10.1080/02786826.2017.1311988">10.1080/02786826.2017.1311988</a>.
141 !! - J.&nbsp;Ching, J.&nbsp;Fast, M.&nbsp;West, and N.&nbsp;Riemer
142 !! (2017) Metrics to quantify the importance of mixing state for
143 !! CCN activity, <i>Atmospheric Chemistry and Physics</i>
144 !! <b>17</b>, 7445-7458, DOI: <a
145 !! href="http://dx.doi.org/10.5194/acp-17-7445-2017">10.5194/acp-17-7445-2017</a>.
146 !! - J.&nbsp;Ching, N.&nbsp;Riemer, and M.&nbsp;West (2016) Black
147 !! carbon mixing state impacts on cloud microphysical properties:
148 !! Effects of aerosol plume and environmental conditions,
149 !! <i>Journal of Geophysical Research</i> <b>121</b>(10),
150 !! 5990-6013, DOI: <a
151 !! href="http://dx.doi.org/10.1002/2016JD024851">10.1002/2016JD024851</a>.
152 !! - J.&nbsp;H.&nbsp;Curtis, M.&nbsp;D.&nbsp;Michelotti,
153 !! N.&nbsp;Riemer, M.&nbsp;Heath, and M.&nbsp;West (2016)
154 !! Accelerated simulation of stochastic particle removal processes
155 !! in particle-resolved aerosol models, <i>Journal of
156 !! Computational Physics</i> <b>322</b>, 21-32, DOI: <a
157 !! href="http://dx.doi.org/10.1016/j.jcp.2016.06.029">10.1016/j.jcp.2016.06.029</a>.
158 !! - R.&nbsp;M.&nbsp;Healy, N.&nbsp;Riemer, J.&nbsp;C.&nbsp;Wenger,
159 !! M.&nbsp;Murphy, M.&nbsp;West, L.&nbsp;Poulain,
160 !! A.&nbsp;Wiedensohler, I.&nbsp;P.&nbsp;O'Connor,
161 !! E.&nbsp;McGillicuddy, J.&nbsp;R.&nbsp;Sodeau, and
162 !! G.&nbsp;J.&nbsp;Evans, Single particle diversity and mixing
163 !! state measurements, <i>Atmospheric Chemistry and Physics</i>
164 !! <b>14</b>, 6289-6299, DOI: <a
165 !! href="http://dx.doi.org/10.5194/acp-14-6289-2014">10.5194/acp-14-6289-2014</a>.
166 !! - J.&nbsp;Tian, N.&nbsp;Riemer, M.&nbsp;West,
167 !! L.&nbsp;Pfaffenberger, H.&nbsp;Schlager, and A.&nbsp;Petzold
168 !! (2014) Modeling the evolution of aerosol particles in a ship
169 !! plume using PartMC-MOSAIC, <i>Atmospheric Chemistry and
170 !! Physics</i> <b>14</b>, 5327-5347, DOI: <a
171 !! href="http://dx.doi.org/10.5194/acp-14-5327-2014">10.5194/acp-14-5327-2014</a>.
172 !! - N.&nbsp;Riemer and M.&nbsp;West (2013) Quantifying aerosol mixing
173 !! state with entropy and diversity measures, <i>Atmospheric
174 !! Chemistry and Physics</i> <b>13</b>, 11423-11439, DOI: <a
175 !! href="http://dx.doi.org/10.5194/acp-13-11423-2013">10.5194/acp-13-11423-2013</a>.
176 !! - M.&nbsp;D.&nbsp;Michelotti, M.&nbsp;T.&nbsp;Heath, and
177 !! M.&nbsp;West (2013) Binning for efficient stochastic multiscale
178 !! particle simulations, <i>Atmospheric Chemistry and Physics</i>
179 !! <b>11</b>(4), 1071-1096, DOI: <a
180 !! href="http://dx.doi.org/10.1137/130908038">10.1137/130908038</a>.
181 !! - J.&nbsp;Ching, N.&nbsp;Riemer, and M.&nbsp;West (2012) Impacts of
182 !! black carbon mixing state on black carbon nucleation scavenging:
183 !! Insights from a particle-resolved model, <i>Journal of
184 !! Geophysical Research</i> <b>117</b>(D23209), DOI: <a
185 !! href="http://dx.doi.org/10.1029/2012JD018269">10.1029/2012JD018269</a>.
186 !! - R.&nbsp;E.&nbsp;L.&nbsp;DeVille, N.&nbsp;Riemer, and
187 !! M.&nbsp;West (2011) Weighted Flow Algorithms (WFA) for
188 !! stochastic particle coagulation, <i>Journal of Computational
189 !! Physics</i> <b>230</b>(23), 8427-8451, DOI: <a
190 !! href="http://dx.doi.org/10.1016/j.jcp.2011.07.027">10.1016/j.jcp.2011.07.027</a>.
191 !! - R.&nbsp;A.&nbsp;Zaveri, J.&nbsp;C.&nbsp;Barnard,
192 !! R.&nbsp;C.&nbsp;Easter, N.&nbsp;Riemer, and M.&nbsp;West (2010)
193 !! Particle-resolved simulation of aerosol size, composition,
194 !! mixing state, and the associated optical and cloud condensation
195 !! nuclei activation properties in an evolving urban plume,
196 !! <i>Journal of Geophysical Research</i> <b>115</b>(D17210), DOI: <a
197 !! href="http://dx.doi.org/10.1029/2009JD013616">10.1029/2009JD013616</a>.
198 !! - N.&nbsp;Riemer, M.&nbsp;West, R.&nbsp;A.&nbsp;Zaveri, and
199 !! R.&nbsp;C.&nbsp;Easter (2010) Estimating black carbon aging
200 !! time-scales with a particle-resolved aerosol model, <i>Journal
201 !! of Aerosol Science</i> <b>41</b>(1), 143-158, DOI: <a
202 !! href="http://dx.doi.org/10.1016/j.jaerosci.2009.08.009">10.1016/j.jaerosci.2009.08.009</a>
203 !! - N.&nbsp;Riemer, M.&nbsp;West, R.&nbsp;A.&nbsp;Zaveri, and
204 !! R.&nbsp;C.&nbsp;Easter (2009) Simulating the evolution of soot
205 !! mixing state with a particle-resolved aerosol model, <i>Journal
206 !! of Geophysical Research</i> <b>114</b>(D09202), DOI: <a
207 !! href="http://dx.doi.org/10.1029/2008JD011073">10.1029/2008JD011073</a>
208 !! - R.&nbsp;McGraw, L.&nbsp;Leng, W.&nbsp;Zhu, N.&nbsp;Riemer, and
209 !! M.&nbsp;West (2008) Aerosol dynamics using the quadrature
210 !! method of moments: Comparing several quadrature schemes with
211 !! particle-resolved simulation, <i>Journal of Physics: Conference
212 !! Series</i> <b>125</b>(012020), DOI: <a
213 !! href="http://dx.doi.org/10.1088/1742-6596/125/1/012020">10.1088/1742-6596/125/1/012020</a>
214 
215 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
216 
217 !> Top level driver.
218 program partmc
219 
220  use pmc_mpi
221  use pmc_bin_grid
222  use pmc_aero_state
223  use pmc_aero_dist
224  use pmc_aero_binned
225  use pmc_coag_kernel
226  use pmc_aero_data
227  use pmc_scenario
228  use pmc_env_state
229  use pmc_run_part
230  use pmc_run_exact
231  use pmc_run_sect
232  use pmc_run_modal
233  use pmc_spec_file
234  use pmc_gas_data
235  use pmc_gas_state
236  use pmc_util
237 #ifdef PMC_USE_CAMP
238  use camp_camp_core
239  use pmc_photolysis
240 #endif
241 #ifdef PMC_USE_SUNDIALS
242  use pmc_condense
243 #endif
244 
245  character(len=300) :: spec_name
246 
247  call pmc_mpi_init()
248 
249  if (pmc_mpi_rank() == 0) then
250  ! only the root process accesses the commandline
251 
252  if (command_argument_count() /= 1) then
253  call print_usage()
254  call die_msg(739173192, "invalid commandline arguments")
255  end if
256 
257  call get_command_argument(1, spec_name)
258  end if
259 
260  call pmc_mpi_bcast_string(spec_name)
261  call partmc_run(spec_name)
262 
263  call pmc_mpi_finalize()
264 
265 contains
266 
267 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
268 
269  !> Print the usage text to stderr.
270  subroutine print_usage()
271 
272  write(*,*) 'Usage: partmc <spec-file>'
273 
274  end subroutine print_usage
275 
276 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
277 
278  !> Do a PartMC run.
279  subroutine partmc_run(spec_name)
280 
281  !> Spec filename.
282  character(len=*), intent(in) :: spec_name
283 
284  type(spec_file_t) :: file
285  character(len=100) :: run_type
286  integer :: i
287 
288  ! check filename (must be "filename.spec")
289  i = len_trim(spec_name)
290  if (spec_name((i-4):i) /= '.spec') then
291  call die_msg(710381938, "input filename must end in .spec")
292  end if
293 
294  if (pmc_mpi_rank() == 0) then
295  ! only the root process does I/O
296  call spec_file_open(spec_name, file)
297  call spec_file_read_string(file, 'run_type', run_type)
298  end if
299 
300  call pmc_mpi_bcast_string(run_type)
301  if (trim(run_type) == 'particle') then
302  call partmc_part(file)
303  elseif (trim(run_type) == 'exact') then
304  call partmc_exact(file)
305  elseif (trim(run_type) == 'sectional') then
306  call partmc_sect(file)
307  elseif (trim(run_type) == 'modal') then
308  call partmc_modal(file)
309  else
310  call die_msg(719261940, "unknown run_type: " // trim(run_type))
311  end if
312 
313  end subroutine partmc_run
314 
315 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
316 
317  !> Run a Monte Carlo simulation.
318  subroutine partmc_part(file)
319 
320  !> Spec file.
321  type(spec_file_t), intent(inout) :: file
322 
323  type(gas_data_t) :: gas_data
324  type(gas_state_t) :: gas_state
325  type(gas_state_t) :: gas_state_init
326  type(aero_data_t) :: aero_data
327  type(aero_dist_t) :: aero_dist_init
328  type(aero_state_t) :: aero_state
329  type(aero_state_t) :: aero_state_init
330  type(scenario_t) :: scenario
331  type(env_state_t) :: env_state
332  type(env_state_t) :: env_state_init
333  type(run_part_opt_t) :: run_part_opt
334 #ifdef PMC_USE_CAMP
335  type(camp_core_t), pointer :: camp_core
336  type(photolysis_t), pointer :: photolysis
337 #endif
338  integer :: i_repeat, i_group
339  integer :: rand_init
340  character, allocatable :: buffer(:)
341  integer :: buffer_size, max_buffer_size
342  integer :: position
343  logical :: do_restart, do_init_equilibrate, aero_mode_type_exp_present
344  character(len=PMC_MAX_FILENAME_LEN) :: restart_filename
345  integer :: dummy_index, dummy_i_repeat
346  real(kind=dp) :: n_part
347 
348  !> \page input_format_particle Input File Format: Particle-Resolved Simulation
349  !!
350  !! See \ref spec_file_format for the input file text format.
351  !!
352  !! A particle-resolved simulation spec file has the parameters:
353  !! - \b run_type (string): must be \c particle
354  !! - \b output_prefix (string): prefix of the output filenames
355  !! --- see \ref output_format for the full name format
356  !! - \b n_repeat (integer): number of repeats
357  !! - \b n_part (integer): number of computational particles to
358  !! simulate (actual number used will vary between <tt>n_part /
359  !! 2</tt> and <tt>n_part * 2</tt> if \c allow_doubling and \c
360  !! allow_halving are \c yes)
361  !! - \b restart (logical): whether to restart the simulation from
362  !! a saved output data file. If \c restart is \c yes, then the
363  !! following parameters must also be provided:
364  !! - \b restart_file (string): name of file from which to load
365  !! restart data, which must be a PartMC output NetCDF file
366  !! - \b do_select_weighting (logical): whether to explicitly select
367  !! the weighting scheme. If \c do_select_weighting is \c yes, then the
368  !! following parameters must also be provided:
369  !! - \subpage input_format_weight_type
370  !! - \b t_max (real, unit s): total simulation time
371  !! - \b del_t (real, unit s): timestep size
372  !! - \b t_output (real, unit s): the interval on which to
373  !! output data to disk (see \ref output_format)
374  !! - \b t_progress (real, unit s): the interval on which to
375  !! write summary information to the screen while running
376  !! - \b do_camp_chem (logical): whether to run <b>CAMP</b>.
377  !! If \c do_camp_chem is \c yes, then the following parameters
378  !! must also be provided:
379  !! - \b camp_config (string): name of JSON file containing a list of \b
380  !! CAMP configuration files.
381  !! - \b gas_data (string): name of file from which to read the gas
382  !! material data (only provide if \c restart is \c no) --- the
383  !! file format should be \subpage input_format_gas_data
384  !! - \b gas_init (string): name of file from which to read the
385  !! initial gas state at the start of the simulation (only
386  !! provide option if \c restart is \c no) --- the file format
387  !! should be \subpage input_format_gas_state
388  !! - \b aerosol_data (string): name of file from which to read the
389  !! aerosol material data (only provide if \c restart is \c no)
390  !! --- the file format should be \subpage input_format_aero_data
391  !! - \b do_fractal (logical): whether to consider particles
392  !! as fractal agglomerates. If \c do_fractal is \c no, then all the
393  !! particles are treated as spherical. If \c do_fractal is \c yes,
394  !! then the following parameters must also be provided:
395  !! - \subpage input_format_fractal
396  !! - \b aerosol_init (string): filename containing the initial
397  !! aerosol state at the start of the simulation (only provide
398  !! option if \c restart is \c no) --- the file format should
399  !! be \subpage input_format_aero_dist
400  !! - \subpage input_format_scenario
401  !! - \subpage input_format_env_state
402  !! - \b do_coagulation (logical): whether to perform particle
403  !! coagulation. If \c do_coagulation is \c yes, then the
404  !! following parameters must also be provided:
405  !! - \subpage input_format_coag_kernel
406  !! - \b do_condensation (logical): whether to perform explicit
407  !! water condensation (requires SUNDIALS support to be compiled
408  !! in; cannot be used simultaneously with MOSAIC). If \c
409  !! do_condensation is \c yes, then the following parameters must
410  !! also be provided:
411  !! - \b do_init_equilibrate (logical): whether to equilibrate
412  !! the water content of each particle before starting the
413  !! simulation, note that \b do_init_equilibriate (sic!)
414  !! spelling will work as well for compatibility
415  !! - \b do_mosaic (logical): whether to use the MOSAIC chemistry
416  !! code (requires support to be compiled in; cannot be used
417  !! simultaneously with condensation). If \c do_mosaic is \c
418  !! yes, then the following parameters must also be provided:
419  !! - \b do_optical (logical): whether to compute optical
420  !! properties of the aerosol particles for the output files ---
421  !! see output_format_aero_state
422  !! - \b do_nucleation (logical): whether to perform particle
423  !! nucleation. If \c do_nucleation is \c yes, then the following
424  !! parameters must also be provided:
425  !! - \subpage input_format_nucleate
426  !! - \b do_freezing (logical): whether to perform particle
427  !! freezing. If \c do_freezing is \c yes, then the following
428  !! parameters must also be provided:
429  !! - \subpage input_format_imf_scheme
430  !! - \b rand_init (integer): if greater than zero then use as
431  !! the seed for the random number generator, or if zero then
432  !! generate a random seed for the random number generator ---
433  !! two simulations on the same machine with the same seed
434  !! (greater than 0) will produce identical output
435  !! - \b allow_doubling (logical): if \c yes, then whenever the
436  !! number of simulated particles falls below <tt>n_part /
437  !! 2</tt>, every particle is duplicated to give better
438  !! statistics
439  !! - \b allow_halving (logical): if \c yes, then whenever the
440  !! number of simulated particles rises above <tt>n_part *
441  !! 2</tt>, half of the particles are removed (chosen randomly)
442  !! to reduce the computational expense
443  !! - \b record_removals (logical): whether to record information
444  !! about aerosol particles removed from the simulation --- see
445  !! \ref output_format_aero_removed
446  !! - \b do_parallel (logical): whether to run in parallel mode
447  !! (requires MPI support to be compiled in). If \c do_parallel
448  !! is \c yes, then the following parameters must also be
449  !! provided:
450  !! - \subpage input_format_output
451  !! - \b mix_timescale (real, unit s): timescale on which to mix
452  !! aerosol particle information amongst processes in an
453  !! attempt to keep the aerosol state consistent (the mixing
454  !! rate is inverse to \c mix_timescale)
455  !! - \b gas_average (logical): whether to average the gas state
456  !! amongst processes each timestep, to ensure uniform gas
457  !! concentrations
458  !! - \b env_average (logical): whether to average the
459  !! environment state amongst processes each timestep, to
460  !! ensure a uniform environment
461  !! - \subpage input_format_parallel_coag
462 
463  ! initialize RNG with random seed for UUID generation
464  call pmc_srand(0, pmc_mpi_rank())
465 
466  if (pmc_mpi_rank() == 0) then
467  call spec_file_read_run_part(file, run_part_opt, aero_data, &
468  aero_state_init, gas_data, gas_state_init, env_state_init, &
469  aero_dist_init, scenario, &
470 #ifdef PMC_USE_CAMP
471  camp_core, photolysis, aero_state, &
472 #endif
473  n_part, rand_init, do_init_equilibrate, do_restart)
474 
475  if (.not. do_restart) then
476  call uuid4_str(run_part_opt%uuid)
477  end if
478  end if
479 
480  call pmc_mpi_broadcast_run_part(run_part_opt, aero_data, &
481  aero_state_init, gas_data, gas_state_init, env_state_init, &
482  aero_dist_init, scenario, &
483 #ifdef PMC_USE_CAMP
484  camp_core, photolysis, aero_state, &
485 #endif
486  n_part, rand_init, do_init_equilibrate, do_restart)
487 
488  ! initialize the chemistry solver
489  if (run_part_opt%do_camp_chem) then
490 #ifdef PMC_USE_CAMP
491  call camp_core%solver_initialize()
492 #endif
493  end if
494 
495  ! re-initialize RNG with the given seed
496  call pmc_rand_finalize()
497  call pmc_srand(rand_init, pmc_mpi_rank())
498 
499  run_part_opt%t_wall_start = system_clock_time()
500 
501  do i_repeat = 1,run_part_opt%n_repeat
502  run_part_opt%i_repeat = i_repeat
503 
504  gas_state = gas_state_init
505  if (do_restart) then
506  aero_state = aero_state_init
507  call aero_state_set_n_part_ideal(aero_state, n_part)
508  else
509  call aero_state_zero(aero_state)
510  aero_mode_type_exp_present &
511  = aero_dist_contains_aero_mode_type(aero_dist_init, &
512  aero_mode_type_exp) &
513  .or. scenario_contains_aero_mode_type(scenario, &
514  aero_mode_type_exp)
515  if (aero_mode_type_exp_present) then
516  call warn_msg(245301880, "using flat weighting only due to " &
517  // "presence of exp aerosol mode")
518  call aero_state_set_weight(aero_state, aero_data, &
520  else
521  call aero_state_set_weight(aero_state, aero_data, &
522  run_part_opt%weighting_type, run_part_opt%weighting_exponent)
523  end if
524  call aero_state_set_n_part_ideal(aero_state, n_part)
525  call aero_state_add_aero_dist_sample(aero_state, aero_data, &
526  aero_dist_init, 1d0, 1d0, 0d0, run_part_opt%allow_doubling, &
527  run_part_opt%allow_halving)
528  end if
529  env_state = env_state_init
530  call scenario_init_env_state(scenario, env_state, &
531  env_state_init%elapsed_time)
532 
533 #ifdef PMC_USE_SUNDIALS
534  if (do_init_equilibrate) then
535  call condense_equilib_particles(env_state, aero_data, aero_state)
536  end if
537 #endif
538 
539  if (run_part_opt%do_camp_chem) then
540 #ifdef PMC_USE_CAMP
541  call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
542  gas_state, run_part_opt, camp_core=camp_core, &
543  photolysis=photolysis)
544 #endif
545  else
546  call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
547  gas_state, run_part_opt)
548  end if
549 
550  end do
551 
552  if (run_part_opt%do_tchem) then
553 #ifdef PMC_USE_TCHEM
554  call pmc_tchem_cleanup()
555 #endif
556  end if
557 
558  call pmc_rand_finalize()
559 
560  end subroutine partmc_part
561 
562 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
563 
564  !> Run an exact solution simulation.
565  subroutine partmc_exact(file)
566 
567  !> Spec file.
568  type(spec_file_t), intent(inout) :: file
569 
570  character(len=100) :: soln_name
571  type(aero_data_t) :: aero_data
572  type(scenario_t) :: scenario
573  type(env_state_t) :: env_state
574  type(aero_dist_t) :: aero_dist_init
575  type(run_exact_opt_t) :: run_exact_opt
576  type(bin_grid_t) :: bin_grid
577  type(gas_data_t) :: gas_data
578  character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
579  type(spec_file_t) :: sub_file
580 
581  !> \page input_format_exact Exact (Analytical) Solution
582  !!
583  !! The coagulation kernel and initial distribution must be matched
584  !! for an exact solution to exist. The valid choices are:
585  !!
586  !! <table>
587  !! <tr><th>Coagulation kernel</th>
588  !! <th>Initial aerosol distribution</th></tr>
589  !! <tr><td>Additive</td>
590  !! <td>Single exponential mode</td></tr>
591  !! <tr><td>Constant</td>
592  !! <td>Single exponential mode</td></tr>
593  !! <tr><td>Zero</td>
594  !! <td>Anything</td></tr>
595  !! </table>
596  !!
597  !! See \ref spec_file_format for the input file text format.
598  !!
599  !! An exact (analytical) simulation spec file has the parameters:
600  !! - \b run_type (string): must be \c exact
601  !! - \b output_prefix (string): prefix of the output filenames ---
602  !! the filenames will be of the form \c PREFIX_SSSSSSSS.nc where
603  !! \c SSSSSSSS is is the eight-digit output index (starting at 1
604  !! and incremented each time the state is output)
605  !! - \b t_max (real, unit s): total simulation time
606  !! - \b t_output (real, unit s): the interval on which to output
607  !! data to disk and to print progress information to the screen
608  !! (see \ref output_format)
609  !! - \subpage input_format_diam_bin_grid
610  !! - \b gas_data (string): name of file from which to read the
611  !! gas material data --- the file format should be
612  !! \subpage input_format_gas_data
613  !! - \b aerosol_data (string): name of file from which to read the
614  !! aerosol material data --- the file format should be
615  !! \subpage input_format_aero_data
616  !! - \b do_fractal (logical): whether to consider particles
617  !! as fractal agglomerates. If \c do_fractal is \c no, then all the
618  !! particles are treated as spherical. If \c do_fractal is \c yes,
619  !! then the following parameters must also be provided:
620  !! - \subpage input_format_fractal
621  !! - \b aerosol_init (string): filename containing the initial
622  !! aerosol state at the start of the simulation --- the file
623  !! format should be \subpage input_format_aero_dist
624  !! - \subpage input_format_scenario
625  !! - \subpage input_format_env_state
626  !! - \b do_coagulation (logical): whether to perform particle
627  !! coagulation. If \c do_coagulation is \c yes, then the
628  !! following parameters must also be provided:
629  !! - \subpage input_format_coag_kernel
630  !!
631  !! Example:
632  !! <pre>
633  !! run_type exact # exact solution
634  !! output_prefix additive_exact # prefix of output files
635  !!
636  !! t_max 600 # total simulation time (s)
637  !! t_output 60 # output interval (0 disables) (s)
638  !!
639  !! n_bin 160 # number of bins
640  !! d_min 1e-8 # minimum diameter (m)
641  !! d_max 1e-3 # maximum diameter (m)
642  !!
643  !! gas_data gas_data.dat # file containing gas data
644  !!
645  !! aerosol_data aero_data.dat # file containing aerosol data
646  !! do_fractal no # whether to do fractal treatment
647  !! aerosol_init aero_init_dist.dat # aerosol initial condition file
648  !!
649  !! temp_profile temp.dat # temperature profile file
650  !! height_profile height.dat # height profile file
651  !! gas_emissions gas_emit.dat # gas emissions file
652  !! gas_background gas_back.dat # background gas mixing ratios file
653  !! aero_emissions aero_emit.dat # aerosol emissions file
654  !! aero_background aero_back.dat # aerosol background file
655  !!
656  !! rel_humidity 0.999 # initial relative humidity (1)
657  !! pressure 1e5 # initial pressure (Pa)
658  !! latitude 0 # latitude (degrees, -90 to 90)
659  !! longitude 0 # longitude (degrees, -180 to 180)
660  !! altitude 0 # altitude (m)
661  !! start_time 0 # start time (s since 00:00 UTC)
662  !! start_day 1 # start day of year (UTC)
663  !!
664  !! do_coagulation yes # whether to do coagulation (yes/no)
665  !! kernel additive # Additive coagulation kernel
666  !! additive_kernel_coeff 1000d0 # Additive kernel constant
667  !! </pre>
668 
669  ! only serial code here
670  if (pmc_mpi_rank() /= 0) then
671  return
672  end if
673 
674  call spec_file_read_run_exact(file, run_exact_opt, aero_data, &
675  bin_grid, gas_data, env_state, aero_dist_init, scenario)
676 
677  call run_exact(bin_grid, scenario, env_state, aero_data, &
678  aero_dist_init, gas_data, run_exact_opt)
679 
680  call pmc_rand_finalize()
681 
682  end subroutine partmc_exact
683 
684 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
685 
686  !> Run a sectional code simulation.
687  subroutine partmc_sect(file)
688 
689  !> Spec file.
690  type(spec_file_t), intent(inout) :: file
691 
692  type(run_sect_opt_t) :: run_sect_opt
693  type(aero_data_t) :: aero_data
694  type(aero_dist_t) :: aero_dist_init
695  type(aero_state_t) :: aero_init
696  type(scenario_t) :: scenario
697  type(env_state_t) :: env_state
698  type(bin_grid_t) :: bin_grid
699  type(gas_data_t) :: gas_data
700  character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
701  type(spec_file_t) :: sub_file
702 
703  !> \page input_format_sectional Sectional Model Simulation
704  !!
705  !! See \ref spec_file_format for the input file text format.
706  !!
707  !! A sectional simulation spec file has the parameters:
708  !! - \b run_type (string): must be \c sectional
709  !! - \b output_prefix (string): prefix of the output filenames ---
710  !! the filenames will be of the form \c PREFIX_SSSSSSSS.nc where
711  !! \c SSSSSSSS is is the eight-digit output index (starting at 1
712  !! and incremented each time the state is output)
713  !! - \b del_t (real, unit s): timestep size
714  !! - \b t_output (real, unit s): the interval on which to
715  !! output data to disk (see \ref output_format)
716  !! - \b t_progress (real, unit s): the interval on which to
717  !! write summary information to the screen while running
718  !! - \subpage input_format_diam_bin_grid
719  !! - \b gas_data (string): name of file from which to read the
720  !! gas material data --- the file format should be
721  !! \subpage input_format_gas_data
722  !! - \b aerosol_data (string): name of file from which to read the
723  !! aerosol material data --- the file format should be
724  !! \subpage input_format_aero_data
725  !! - \b do_fractal (logical): whether to consider particles
726  !! as fractal agglomerates. If \c do_fractal is \c no, then all the
727  !! particles are treated as spherical. If \c do_fractal is \c yes,
728  !! then the following parameters must also be provided:
729  !! - \subpage input_format_fractal
730  !! - \b aerosol_init (string): filename containing the initial
731  !! aerosol state at the start of the simulation --- the file
732  !! format should be \subpage input_format_aero_dist
733  !! - \subpage input_format_scenario
734  !! - \subpage input_format_env_state
735  !! - \b do_coagulation (logical): whether to perform particle
736  !! coagulation. If \c do_coagulation is \c yes, then the
737  !! following parameters must also be provided:
738  !! - \subpage input_format_coag_kernel
739  !!
740  !! Example:
741  !! <pre>
742  !! run_type sectional # sectional code run
743  !! output_prefix brown_sect # prefix of output files
744  !!
745  !! t_max 86400 # total simulation time (s)
746  !! del_t 60 # timestep (s)
747  !! t_output 3600 # output interval (0 disables) (s)
748  !! t_progress 600 # progress printing interval (0 disables) (s)
749  !!
750  !! n_bin 220 # number of bins
751  !! d_min 1e-10 # minimum diameter (m)
752  !! d_max 1e-4 # maximum diameter (m)
753  !!
754  !! gas_data gas_data.dat # file containing gas data
755  !! aerosol_data aero_data.dat # file containing aerosol data
756  !! do_fractal no # whether to do fractal treatment
757  !! aerosol_init aero_init_dist.dat # initial aerosol distribution
758  !!
759  !! temp_profile temp.dat # temperature profile file
760  !! height_profile height.dat # height profile file
761  !! gas_emissions gas_emit.dat # gas emissions file
762  !! gas_background gas_back.dat # background gas mixing ratios file
763  !! aero_emissions aero_emit.dat # aerosol emissions file
764  !! aero_background aero_back.dat # aerosol background file
765  !!
766  !! rel_humidity 0.999 # initial relative humidity (1)
767  !! pressure 1e5 # initial pressure (Pa)
768  !! latitude 0 # latitude (degrees_north, -90 to 90)
769  !! longitude 0 # longitude (degrees_east, -180 to 180)
770  !! altitude 0 # altitude (m)
771  !! start_time 0 # start time (s since 00:00 UTC)
772  !! start_day 1 # start day of year (UTC)
773  !!
774  !! do_coagulation yes # whether to do coagulation (yes/no)
775  !! kernel brown # coagulation kernel
776  !! </pre>
777 
778  ! only serial code here
779  if (pmc_mpi_rank() /= 0) then
780  return
781  end if
782 
783  call spec_file_read_run_sect(file, run_sect_opt, aero_data, bin_grid, &
784  gas_data, env_state, aero_dist_init, scenario)
785 
786  call run_sect(bin_grid, gas_data, aero_data, aero_dist_init, scenario, &
787  env_state, run_sect_opt)
788 
789  call pmc_rand_finalize()
790 
791  end subroutine partmc_sect
792 
793 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
794 
795  !> Run a modal code simulation.
796  subroutine partmc_modal(file)
797 
798  !> Spec file
799  type(spec_file_t), intent(inout) :: file
800 
801  type(run_modal_opt_t) :: run_modal_opt
802  type(aero_data_t) :: aero_data
803  type(aero_dist_t) :: aero_dist_init
804  type(scenario_t) :: scenario
805  type(env_state_t) :: env_state
806  type(bin_grid_t) :: bin_grid
807  type(gas_data_t) :: gas_data
808 
809  !> \page input_format_modal Modal Aerosol Simulation
810  !!
811  !! See \ref spec_file_format for the input file text format.
812  !!
813  !! A modal simulation spec file has the parameters:
814  !! - \b run_type (string): must be \c modal
815  !! - \b output_prefix (string): prefix of the output filenames ---
816  !! the filenames will be of the form \c PREFIX_SSSSSSSS.nc where
817  !! \c SSSSSSSS is the eight-digit output index (starting at 1
818  !! and incremented each time the state is output)
819  !! - \b t_max (real, unit s): total simulation time
820  !! - \b del_t (real, unit s): timestep size
821  !! - \b t_output (real, unit s): the interval on which to output
822  !! data to disk (see \ref output_format)
823  !! - \b t_progress (real, unit s): the interval on which to write
824  !! summary information to the screen while running
825  !! - \subpage input_format_radius_bin_grid
826  !! - \b do_camp_chem (logical): must be \c no (not currently supported)
827  !! - \b do_tchem (logical): must be \c no (not currently supported)
828  !! - \b gas_data (string): name of file from which to read the
829  !! gas material data --- the file format should be
830  !! \subpage input_format_gas_data
831  !! - \b aerosol_data (string): name of file from which to read the
832  !! aerosol material data (single species only) --- the file
833  !! format should be \subpage input_format_aero_data
834  !! - \b do_fractal (logical): whether to use fractal treatment
835  !! (must be \c no; not currently supported)
836  !! - \b aerosol_init (string): filename for the initial lognormal
837  !! aerosol distribution --- the file format should be
838  !! \subpage input_format_aero_dist
839  !! - \subpage input_format_scenario
840  !! - \subpage input_format_env_state
841  !! - \b do_coagulation (logical): must be \c no (not currently supported)
842  !! - \b do_condensation (logical): must be \c no (not currently supported)
843  !! - \b do_mosaic (logical): must be \c no (not currently supported)
844  !! - \b do_optical (logical): must be \c no (not currently supported)
845  !! - \b do_nucleation (logical): must be \c no (not currently supported)
846  !! - \b do_immersion_freezing (logical): must be \c no (not currently
847  !! supported)
848  !! - \b do_parallel (logical): must be \c no (not currently supported)
849  !!
850  !! \note Modal runs currently support only the \c drydep and \c none
851  !! loss functions. Aerosol emissions and background dilution are not
852  !! supported; their rates must be zero in the scenario files. The
853  !! options \c do_camp_chem, \c do_tchem, \c do_coagulation,
854  !! \c do_condensation, \c do_mosaic, \c do_optical, \c do_nucleation,
855  !! \c do_immersion_freezing, and \c do_parallel are included for future
856  !! extensibility but must currently be set to \c no --- setting any of
857  !! them to \c yes will produce a fatal error.
858  !!
859  !! Example:
860  !! <pre>
861  !! run_type modal # modal run
862  !! output_prefix out/modal # prefix of output files
863  !!
864  !! t_max 28800 # total simulation time (s)
865  !! del_t 60 # timestep (s)
866  !! t_output 3600 # output interval (0 disables) (s)
867  !! t_progress 0 # progress printing interval (0 disables) (s)
868  !!
869  !! n_bin 1000 # number of bins (for processing purposes)
870  !! d_min 4e-8 # minimum diameter (m)
871  !! d_max 2.5e-3 # maximum diameter (m)
872  !!
873  !! do_camp_chem no # whether to use CAMP for chemistry (yes/no)
874  !! do_tchem no # whether to use TChem for chemistry (yes/no)
875  !!
876  !! gas_data gas_data.dat # file containing gas data
877  !! aerosol_data aero_data.dat # file containing aerosol data
878  !! do_fractal no # use fractal treatment (yes/no)
879  !! aerosol_init aero_init_dist.dat # aerosol initial condition file
880  !!
881  !! temp_profile temp.dat # temperature profile file
882  !! pressure_profile pres.dat # pressure profile file
883  !! height_profile height.dat # height profile file
884  !! gas_emissions gas_emit.dat # gas emissions file
885  !! gas_background gas_back.dat # background gas concentrations file
886  !! aero_emissions aero_emit.dat # aerosol emissions file
887  !! aero_background aero_back.dat # aerosol background file
888  !! loss_function drydep # loss function specification
889  !! drydep_params drydep_params.dat # dry deposition parameters
890  !!
891  !! rel_humidity 0.95 # initial relative humidity (1)
892  !! latitude 0 # latitude (degrees, -90 to 90)
893  !! longitude 0 # longitude (degrees, -180 to 180)
894  !! altitude 0 # altitude (m)
895  !! start_time 21600 # start time (s since 00:00 UTC)
896  !! start_day 200 # start day of year (UTC)
897  !!
898  !! do_coagulation no # whether to do coagulation (yes/no)
899  !! do_condensation no # whether to do condensation (yes/no)
900  !! do_mosaic no # whether to do MOSAIC (yes/no)
901  !! do_optical no # whether to compute optical props (yes/no)
902  !! do_nucleation no # whether to do nucleation (yes/no)
903  !! do_immersion_freezing no # whether to do freezing (yes/no)
904  !! do_parallel no # whether to run in parallel (yes/no)
905  !! </pre>
906 
907  ! only serial code here
908  if (pmc_mpi_rank() /= 0) then
909  return
910  end if
911 
912  call spec_file_read_run_modal(file, run_modal_opt, aero_data, bin_grid, &
913  gas_data, env_state, aero_dist_init, scenario)
914 
915  call run_modal(aero_data, aero_dist_init, scenario, &
916  env_state, gas_data, bin_grid, run_modal_opt)
917 
918  call pmc_rand_finalize()
919 
920  end subroutine partmc_modal
921 
922 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
923 
924 end program partmc
pmc_mpi::pmc_mpi_init
subroutine pmc_mpi_init()
Initialize MPI.
Definition: mpi.F90:56
pmc_run_sect::run_sect_opt_t
Options controlling the operation of run_sect().
Definition: run_sect.F90:32
pmc_run_modal::run_modal
subroutine run_modal(aero_data, aero_dist, scenario, env_state, gas_data, bin_grid, run_modal_opt)
Run a modal simulation.
Definition: run_modal.F90:59
pmc_aero_state::aero_state_zero
subroutine aero_state_zero(aero_state)
Resets an aero_state to have zero particles per bin.
Definition: aero_state.F90:350
pmc_scenario::scenario_contains_aero_mode_type
elemental logical function scenario_contains_aero_mode_type(scenario, aero_mode_type)
Whether any of the contained aerosol modes are of the given type.
Definition: scenario.F90:1129
pmc_run_sect
1D sectional simulation.
Definition: run_sect.F90:17
pmc_gas_data::gas_data_t
Constant gas data.
Definition: gas_data.F90:35
pmc_mpi
Wrapper functions for MPI.
Definition: mpi.F90:13
pmc_util::system_clock_time
real(kind=dp) function system_clock_time()
Returns the current system clock time in seconds.
Definition: util.F90:2009
pmc_run_modal::run_modal_opt_t
Options controlling the operation of run_modal()
Definition: run_modal.F90:21
pmc_aero_state::aero_state_add_aero_dist_sample
subroutine aero_state_add_aero_dist_sample(aero_state, aero_data, aero_dist, sample_prop, characteristic_factor, create_time, allow_doubling, allow_halving, n_part_add)
Generates a Poisson sample of an aero_dist, adding to aero_state, with the given sample proportion.
Definition: aero_state.F90:761
pmc_run_modal
1D modal simulation.
Definition: run_modal.F90:6
pmc_scenario
The scenario_t structure and associated subroutines.
Definition: scenario.F90:9
pmc_scenario::scenario_t
Scenario data.
Definition: scenario.F90:86
pmc_gas_data
The gas_data_t structure and associated subroutines.
Definition: gas_data.F90:9
pmc_run_part::run_part
subroutine run_part(scenario, env_state, aero_data, aero_state, gas_data, gas_state, run_part_opt)
Do a particle-resolved Monte Carlo simulation.
Definition: run_part.F90:141
partmc
program partmc
Top level driver.
Definition: partmc.F90:218
pmc_aero_state::aero_state_set_weight
subroutine aero_state_set_weight(aero_state, aero_data, weight_type, exponent)
Sets the weighting functions for an aero_state.
Definition: aero_state.F90:186
pmc_util::die_msg
subroutine die_msg(code, error_msg)
Error immediately.
Definition: util.F90:135
pmc_mpi::pmc_mpi_rank
integer function pmc_mpi_rank()
Returns the rank of the current process.
Definition: mpi.F90:117
pmc_aero_state::aero_state_set_n_part_ideal
subroutine aero_state_set_n_part_ideal(aero_state, n_part)
Set the ideal number of particles to the given value. The aero_state%awa must be already set correctl...
Definition: aero_state.F90:242
pmc_constants::dp
integer, parameter dp
Kind of a double precision real number.
Definition: constants.F90:12
pmc_coag_kernel
Generic coagulation kernel.
Definition: coag_kernel.F90:9
pmc_condense
Water condensation onto aerosol particles.
Definition: condense.F90:29
pmc_run_part::run_part_opt_t
Options controlling the execution of run_part().
Definition: run_part.F90:50
pmc_spec_file
Reading formatted text input.
Definition: spec_file.F90:43
pmc_condense::condense_equilib_particles
subroutine condense_equilib_particles(env_state, aero_data, aero_state)
Call condense_equilib_particle() on each particle in the aerosol to ensure that every particle has it...
Definition: condense.F90:747
pmc_env_state::env_state_t
Current environment state.
Definition: env_state.F90:29
pmc_aero_state
The aero_state_t structure and assocated subroutines.
Definition: aero_state.F90:9
pmc_run_modal::spec_file_read_run_modal
subroutine spec_file_read_run_modal(file, run_modal_opt, aero_data, bin_grid, gas_data, env_state, aero_dist_init, scenario)
Read the specification for a run_modal simulation from a spec file.
Definition: run_modal.F90:158
pmc_aero_state::aero_state_weight_flat
integer, parameter aero_state_weight_flat
Single flat weighting scheme.
Definition: aero_state.F90:41
pmc_spec_file::spec_file_t
An input file with extra data for printing messages.
Definition: spec_file.F90:59
pmc_rand::pmc_srand
subroutine pmc_srand(seed, offset)
Initializes the random number generator to the state defined by the given seed plus offset....
Definition: rand.F90:67
pmc_gas_state
The gas_state_t structure and associated subroutines.
Definition: gas_state.F90:9
pmc_mpi::pmc_mpi_finalize
subroutine pmc_mpi_finalize()
Shut down MPI.
Definition: mpi.F90:89
pmc_util::warn_msg
subroutine warn_msg(code, warning_msg, already_warned)
Prints a warning message.
Definition: util.F90:38
pmc_run_sect::spec_file_read_run_sect
subroutine spec_file_read_run_sect(file, run_sect_opt, aero_data, bin_grid, gas_data, env_state, aero_dist_init, scenario)
Read the specification for a run_sect simulation from a spec file.
Definition: run_sect.F90:205
pmc_aero_dist
The aero_dist_t structure and associated subroutines.
Definition: aero_dist.F90:18
pmc_run_part::pmc_mpi_broadcast_run_part
subroutine pmc_mpi_broadcast_run_part(run_part_opt, aero_data, aero_state_init, gas_data, gas_state_init, env_state_init, aero_dist_init, scenario, n_part, rand_init, do_init_equilibrate, do_restart)
Read the specification for a run_part simulation from a spec file.
Definition: run_part.F90:1129
print_usage
subroutine print_usage()
Print the usage text to stderr.
Definition: partmc.F90:271
pmc_spec_file::spec_file_open
subroutine spec_file_open(filename, file)
Open a spec file for reading.
Definition: spec_file.F90:112
pmc_photolysis
The photolysis_t type and related functions.
Definition: photolysis.F90:9
pmc_run_part
Monte Carlo simulation.
Definition: run_part.F90:9
pmc_env_state
The env_state_t structure and associated subroutines.
Definition: env_state.F90:9
pmc_run_exact::run_exact
subroutine run_exact(bin_grid, scenario, env_state, aero_data, aero_dist_init, gas_data, run_exact_opt)
Run an exact simulation.
Definition: run_exact.F90:46
pmc_gas_state::gas_state_t
Current state of the gas mixing ratios in the system.
Definition: gas_state.F90:33
pmc_rand::uuid4_str
subroutine uuid4_str(uuid)
Generate a version 4 UUID as a string.
Definition: rand.F90:661
pmc_aero_data::aero_data_t
Aerosol material properties and associated data.
Definition: aero_data.F90:55
pmc_run_exact::run_exact_opt_t
Options controlling the execution of run_exact().
Definition: run_exact.F90:24
pmc_aero_dist::aero_dist_t
A complete aerosol distribution, consisting of several modes.
Definition: aero_dist.F90:33
pmc_run_part::spec_file_read_run_part
subroutine spec_file_read_run_part(file, run_part_opt, aero_data, aero_state_init, gas_data, gas_state_init, env_state_init, aero_dist_init, scenario, n_part, rand_init, do_init_equilibrate, do_restart)
Read the specification for a run_part simulation from a spec file.
Definition: run_part.F90:494
pmc_util
Common utility subroutines.
Definition: util.F90:9
pmc_run_exact::spec_file_read_run_exact
subroutine spec_file_read_run_exact(file, run_exact_opt, aero_data, bin_grid, gas_data, env_state, aero_dist_init, scenario)
Read the specification for a run_exact simulation from a spec file.
Definition: run_exact.F90:92
pmc_scenario::scenario_init_env_state
subroutine scenario_init_env_state(scenario, env_state, time)
Initialize the time-dependent contents of the environment. Thereafter scenario_update_env_state() sho...
Definition: scenario.F90:145
pmc_aero_binned
The aero_binned_t structure and associated subroutines.
Definition: aero_binned.F90:9
pmc_spec_file::spec_file_read_string
subroutine spec_file_read_string(file, name, var)
Read a string from a spec file that must have a given name.
Definition: spec_file.F90:624
pmc_bin_grid
The bin_grid_t structure and associated subroutines.
Definition: bin_grid.F90:9
pmc_aero_data
The aero_data_t structure and associated subroutines.
Definition: aero_data.F90:9
pmc_run_sect::run_sect
subroutine run_sect(bin_grid, gas_data, aero_data, aero_dist, scenario, env_state, run_sect_opt)
Run a sectional simulation.
Definition: run_sect.F90:58
pmc_bin_grid::bin_grid_t
1D grid, either logarithmic or linear.
Definition: bin_grid.F90:33
partmc_run
subroutine partmc_run(spec_name)
Do a PartMC run.
Definition: partmc.F90:280
pmc_rand::pmc_rand_finalize
subroutine pmc_rand_finalize()
Cleanup the random number generator.
Definition: rand.F90:119
pmc_aero_dist::aero_dist_contains_aero_mode_type
elemental logical function aero_dist_contains_aero_mode_type(aero_dist, aero_mode_type)
Whether any of the modes are of the given type.
Definition: aero_dist.F90:155
pmc_mpi::pmc_mpi_bcast_string
subroutine pmc_mpi_bcast_string(val)
Broadcast the given value from process 0 to all other processes.
Definition: mpi.F90:307
pmc_aero_state::aero_state_t
The current collection of aerosol particles.
Definition: aero_state.F90:69
pmc_run_exact
Exact solution simulation.
Definition: run_exact.F90:9