Go to the documentation of this file.
241 #ifdef PMC_USE_SUNDIALS
245 character(len=300) :: spec_name
252 if (command_argument_count() /= 1)
then
254 call die_msg(739173192,
"invalid commandline arguments")
257 call get_command_argument(1, spec_name)
272 write(*,*)
'Usage: partmc <spec-file>'
282 character(len=*),
intent(in) :: spec_name
285 character(len=100) :: run_type
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")
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)
310 call die_msg(719261940,
"unknown run_type: " // trim(run_type))
318 subroutine partmc_part(file)
335 type(camp_core_t),
pointer :: camp_core
336 type(photolysis_t),
pointer :: photolysis
338 integer :: i_repeat, i_group
340 character,
allocatable :: buffer(:)
341 integer :: buffer_size, max_buffer_size
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
468 aero_state_init, gas_data, gas_state_init, env_state_init, &
469 aero_dist_init, scenario, &
471 camp_core, photolysis, aero_state, &
473 n_part, rand_init, do_init_equilibrate, do_restart)
475 if (.not. do_restart)
then
481 aero_state_init, gas_data, gas_state_init, env_state_init, &
482 aero_dist_init, scenario, &
484 camp_core, photolysis, aero_state, &
486 n_part, rand_init, do_init_equilibrate, do_restart)
489 if (run_part_opt%do_camp_chem)
then
491 call camp_core%solver_initialize()
501 do i_repeat = 1,run_part_opt%n_repeat
502 run_part_opt%i_repeat = i_repeat
504 gas_state = gas_state_init
506 aero_state = aero_state_init
510 aero_mode_type_exp_present &
512 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")
522 run_part_opt%weighting_type, run_part_opt%weighting_exponent)
526 aero_dist_init, 1d0, 1d0, 0d0, run_part_opt%allow_doubling, &
527 run_part_opt%allow_halving)
529 env_state = env_state_init
531 env_state_init%elapsed_time)
533 #ifdef PMC_USE_SUNDIALS
534 if (do_init_equilibrate)
then
539 if (run_part_opt%do_camp_chem)
then
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)
546 call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
547 gas_state, run_part_opt)
552 if (run_part_opt%do_tchem)
then
554 call pmc_tchem_cleanup()
560 end subroutine partmc_part
565 subroutine partmc_exact(file)
570 character(len=100) :: soln_name
578 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
675 bin_grid, gas_data, env_state, aero_dist_init, scenario)
677 call run_exact(bin_grid, scenario, env_state, aero_data, &
678 aero_dist_init, gas_data, run_exact_opt)
682 end subroutine partmc_exact
687 subroutine partmc_sect(file)
700 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
784 gas_data, env_state, aero_dist_init, scenario)
786 call run_sect(bin_grid, gas_data, aero_data, aero_dist_init, scenario, &
787 env_state, run_sect_opt)
791 end subroutine partmc_sect
796 subroutine partmc_modal(file)
913 gas_data, env_state, aero_dist_init, scenario)
915 call run_modal(aero_data, aero_dist_init, scenario, &
916 env_state, gas_data, bin_grid, run_modal_opt)
920 end subroutine partmc_modal
subroutine pmc_mpi_init()
Initialize MPI.
Options controlling the operation of run_sect().
subroutine run_modal(aero_data, aero_dist, scenario, env_state, gas_data, bin_grid, run_modal_opt)
Run a modal simulation.
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.
Options controlling the operation of run_modal()
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.
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.
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.