Go to the documentation of this file.
237 #ifdef PMC_USE_SUNDIALS
241 character(len=300) :: spec_name
248 if (command_argument_count() /= 1)
then
250 call die_msg(739173192,
"invalid commandline arguments")
253 call get_command_argument(1, spec_name)
268 write(*,*)
'Usage: partmc <spec-file>'
278 character(len=*),
intent(in) :: spec_name
281 character(len=100) :: run_type
285 i = len_trim(spec_name)
286 if (spec_name((i-4):i) /=
'.spec')
then
287 call die_msg(710381938,
"input filename must end in .spec")
297 if (trim(run_type) ==
'particle')
then
298 call partmc_part(file)
299 elseif (trim(run_type) ==
'exact')
then
300 call partmc_exact(file)
301 elseif (trim(run_type) ==
'sectional')
then
302 call partmc_sect(file)
304 call die_msg(719261940,
"unknown run_type: " // trim(run_type))
312 subroutine partmc_part(file)
329 type(camp_core_t),
pointer :: camp_core
330 type(photolysis_t),
pointer :: photolysis
332 integer :: i_repeat, i_group
334 character,
allocatable :: buffer(:)
335 integer :: buffer_size, max_buffer_size
337 logical :: do_restart, do_init_equilibrate, aero_mode_type_exp_present
338 character(len=PMC_MAX_FILENAME_LEN) :: restart_filename
339 integer :: dummy_index, dummy_i_repeat
340 real(kind=
dp) :: n_part
458 aero_state_init, gas_data, gas_state_init, env_state_init, &
459 aero_dist_init, scenario, &
461 camp_core, photolysis, aero_state, &
463 n_part, rand_init, do_init_equilibrate, do_restart)
465 if (.not. do_restart)
then
471 aero_state_init, gas_data, gas_state_init, env_state_init, &
472 aero_dist_init, scenario, &
474 camp_core, photolysis, aero_state, &
476 n_part, rand_init, do_init_equilibrate, do_restart)
479 if (run_part_opt%do_camp_chem)
then
481 call camp_core%solver_initialize()
491 do i_repeat = 1,run_part_opt%n_repeat
492 run_part_opt%i_repeat = i_repeat
494 gas_state = gas_state_init
496 aero_state = aero_state_init
500 aero_mode_type_exp_present &
502 aero_mode_type_exp) &
505 if (aero_mode_type_exp_present)
then
506 call warn_msg(245301880,
"using flat weighting only due to " &
507 //
"presence of exp aerosol mode")
512 run_part_opt%weighting_type, run_part_opt%weighting_exponent)
516 aero_dist_init, 1d0, 1d0, 0d0, run_part_opt%allow_doubling, &
517 run_part_opt%allow_halving)
519 env_state = env_state_init
521 env_state_init%elapsed_time)
523 #ifdef PMC_USE_SUNDIALS
524 if (do_init_equilibrate)
then
529 if (run_part_opt%do_camp_chem)
then
531 call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
532 gas_state, run_part_opt, camp_core=camp_core, &
533 photolysis=photolysis)
536 call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
537 gas_state, run_part_opt)
542 if (run_part_opt%do_tchem)
then
544 call pmc_tchem_cleanup()
550 end subroutine partmc_part
555 subroutine partmc_exact(file)
560 character(len=100) :: soln_name
568 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
665 bin_grid, gas_data, env_state, aero_dist_init, scenario)
667 call run_exact(bin_grid, scenario, env_state, aero_data, &
668 aero_dist_init, gas_data, run_exact_opt)
672 end subroutine partmc_exact
677 subroutine partmc_sect(file)
690 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
774 gas_data, env_state, aero_dist_init, scenario)
776 call run_sect(bin_grid, gas_data, aero_data, aero_dist_init, scenario, &
777 env_state, run_sect_opt)
781 end subroutine partmc_sect
subroutine pmc_mpi_init()
Initialize MPI.
Options controlling the operation of run_sect().
subroutine aero_state_zero(aero_state)
Resets an aero_state to have zero particles per bin.
elemental logical function scenario_contains_aero_mode_type(scenario, aero_mode_type)
Whether any of the contained aerosol modes are of the given type.
Wrapper functions for MPI.
real(kind=dp) function system_clock_time()
Returns the current system clock time in seconds.
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.
The scenario_t structure and associated subroutines.
The gas_data_t structure and associated subroutines.
subroutine run_part(scenario, env_state, aero_data, aero_state, gas_data, gas_state, run_part_opt)
Do a particle-resolved Monte Carlo simulation.
program partmc
Top level driver.
subroutine aero_state_set_weight(aero_state, aero_data, weight_type, exponent)
Sets the weighting functions for an aero_state.
subroutine die_msg(code, error_msg)
Error immediately.
integer function pmc_mpi_rank()
Returns the rank of the current process.
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...
integer, parameter dp
Kind of a double precision real number.
Generic coagulation kernel.
Water condensation onto aerosol particles.
Options controlling the execution of run_part().
Reading formatted text input.
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...
Current environment state.
The aero_state_t structure and assocated subroutines.
integer, parameter aero_state_weight_flat
Single flat weighting scheme.
An input file with extra data for printing messages.
subroutine pmc_srand(seed, offset)
Initializes the random number generator to the state defined by the given seed plus offset....
The gas_state_t structure and associated subroutines.
subroutine pmc_mpi_finalize()
Shut down MPI.
subroutine warn_msg(code, warning_msg, already_warned)
Prints a warning message.
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.
The aero_dist_t structure and associated subroutines.
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.
subroutine print_usage()
Print the usage text to stderr.
subroutine spec_file_open(filename, file)
Open a spec file for reading.
The photolysis_t type and related functions.
The env_state_t structure and associated subroutines.
subroutine run_exact(bin_grid, scenario, env_state, aero_data, aero_dist_init, gas_data, run_exact_opt)
Run an exact simulation.
Current state of the gas mixing ratios in the system.
subroutine uuid4_str(uuid)
Generate a version 4 UUID as a string.
Aerosol material properties and associated data.
Options controlling the execution of run_exact().
A complete aerosol distribution, consisting of several modes.
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.
Common utility subroutines.
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.
subroutine scenario_init_env_state(scenario, env_state, time)
Initialize the time-dependent contents of the environment. Thereafter scenario_update_env_state() sho...
The aero_binned_t structure and associated subroutines.
subroutine spec_file_read_string(file, name, var)
Read a string from a spec file that must have a given name.
The bin_grid_t structure and associated subroutines.
The aero_data_t structure and associated subroutines.
subroutine run_sect(bin_grid, gas_data, aero_data, aero_dist, scenario, env_state, run_sect_opt)
Run a sectional simulation.
1D grid, either logarithmic or linear.
subroutine partmc_run(spec_name)
Do a PartMC run.
subroutine pmc_rand_finalize()
Cleanup the random number generator.
elemental logical function aero_dist_contains_aero_mode_type(aero_dist, aero_mode_type)
Whether any of the modes are of the given type.
subroutine pmc_mpi_bcast_string(val)
Broadcast the given value from process 0 to all other processes.
The current collection of aerosol particles.
Exact solution simulation.