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) :: dummy_time, dummy_del_t, n_part
341 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
343 character(len=PMC_MAX_FILENAME_LEN) :: camp_config_filename
460 run_part_opt%output_prefix)
474 run_part_opt%do_camp_chem)
475 if (run_part_opt%do_camp_chem)
then
478 camp_config_filename)
479 camp_core => camp_core_t(camp_config_filename)
480 call camp_core%initialize()
481 photolysis => photolysis_t(camp_core)
484 'cannot do camp chem, CAMP support not compiled in')
489 call input_state(restart_filename, dummy_index, dummy_time, &
490 dummy_del_t, dummy_i_repeat, run_part_opt%uuid, aero_data, &
491 aero_state_init, gas_data, gas_state_init, env_state_init)
494 if (.not. do_restart)
then
495 env_state_init%elapsed_time = 0d0
496 if (.not. run_part_opt%do_camp_chem)
then
499 call spec_file_read_gas_data(sub_file, gas_data)
503 call gas_data_initialize(gas_data, camp_core)
508 call spec_file_read_gas_state(sub_file, gas_data, &
512 if (.not. run_part_opt%do_camp_chem)
then
515 call spec_file_read_aero_data(sub_file, aero_data)
523 call spec_file_read_fractal(file, aero_data%fractal)
527 call spec_file_read_aero_dist(sub_file, aero_data, aero_dist_init)
531 call spec_file_read_scenario(file, gas_data, aero_data, scenario)
532 call spec_file_read_env_state(file, env_state_init)
535 run_part_opt%do_coagulation)
536 if (run_part_opt%do_coagulation)
then
537 call spec_file_read_coag_kernel_type(file, &
538 run_part_opt%coag_kernel_type)
544 run_part_opt%do_condensation)
545 #ifndef PMC_USE_SUNDIALS
547 run_part_opt%do_condensation .eqv. .false., &
548 "cannot use condensation, SUNDIALS support is not compiled in")
550 do_init_equilibrate = .false.
551 if (run_part_opt%do_condensation)
then
557 if (run_part_opt%do_mosaic .and. (.not. mosaic_support()))
then
559 'cannot use MOSAIC, support is not compiled in')
561 if (run_part_opt%do_mosaic .and. run_part_opt%do_condensation)
then
563 'cannot use MOSAIC and condensation simultaneously')
565 if (run_part_opt%do_mosaic)
then
567 run_part_opt%do_optical)
569 run_part_opt%do_optical = .false.
573 run_part_opt%do_nucleation)
574 if (run_part_opt%do_nucleation)
then
575 call spec_file_read_nucleate_type(file, aero_data, &
576 run_part_opt%nucleate_type, run_part_opt%nucleate_source)
578 run_part_opt%nucleate_type = nucleate_type_invalid
583 run_part_opt%allow_doubling)
585 run_part_opt%allow_halving)
586 if (.not. do_restart)
then
588 run_part_opt%do_select_weighting)
589 if (run_part_opt%do_select_weighting)
then
590 call spec_file_read_aero_state_weighting_type(file, &
591 run_part_opt%weighting_type, run_part_opt%weighting_exponent)
594 run_part_opt%weighting_exponent = 0.0d0
598 run_part_opt%record_removals)
601 run_part_opt%do_parallel)
602 if (run_part_opt%do_parallel)
then
605 'cannot use parallel mode, support is not compiled in')
607 call spec_file_read_output_type(file, run_part_opt%output_type)
609 run_part_opt%mix_timescale)
611 run_part_opt%gas_average)
613 run_part_opt%env_average)
614 call spec_file_read_parallel_coag_type(file, &
615 run_part_opt%parallel_coag_type)
617 run_part_opt%output_type = output_type_single
618 run_part_opt%mix_timescale = 0d0
619 run_part_opt%gas_average = .false.
620 run_part_opt%env_average = .false.
632 if (.not. do_restart)
then
640 max_buffer_size = max_buffer_size &
642 max_buffer_size = max_buffer_size &
644 max_buffer_size = max_buffer_size &
646 max_buffer_size = max_buffer_size &
648 max_buffer_size = max_buffer_size &
650 max_buffer_size = max_buffer_size &
652 max_buffer_size = max_buffer_size &
654 max_buffer_size = max_buffer_size &
656 max_buffer_size = max_buffer_size &
658 max_buffer_size = max_buffer_size &
660 max_buffer_size = max_buffer_size &
662 max_buffer_size = max_buffer_size &
665 allocate(buffer(max_buffer_size))
680 call assert(181905491, position <= max_buffer_size)
681 buffer_size = position
689 allocate(buffer(buffer_size))
710 call assert(143770146, position == buffer_size)
718 if (run_part_opt%do_camp_chem)
then
720 call camp_core%solver_initialize()
728 call cpu_time(run_part_opt%t_wall_start)
730 do i_repeat = 1,run_part_opt%n_repeat
731 run_part_opt%i_repeat = i_repeat
733 gas_state = gas_state_init
735 aero_state = aero_state_init
739 aero_mode_type_exp_present &
741 aero_mode_type_exp) &
744 if (aero_mode_type_exp_present)
then
745 call warn_msg(245301880,
"using flat weighting only due to " &
746 //
"presence of exp aerosol mode")
751 run_part_opt%weighting_type, run_part_opt%weighting_exponent)
755 aero_dist_init, 1d0, 0d0, run_part_opt%allow_doubling, &
756 run_part_opt%allow_halving)
758 env_state = env_state_init
760 env_state_init%elapsed_time)
762 #ifdef PMC_USE_SUNDIALS
763 if (do_init_equilibrate)
then
768 if (run_part_opt%do_camp_chem)
then
770 call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
771 gas_state, run_part_opt, camp_core=camp_core, &
772 photolysis=photolysis)
775 call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
776 gas_state, run_part_opt)
783 end subroutine partmc_part
788 subroutine partmc_exact(file)
793 character(len=100) :: soln_name
801 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
901 call spec_file_read_radius_bin_grid(file, bin_grid)
905 call spec_file_read_gas_data(sub_file, gas_data)
910 call spec_file_read_aero_data(sub_file, aero_data)
913 call spec_file_read_fractal(file, aero_data%fractal)
917 call spec_file_read_aero_dist(sub_file, aero_data, aero_dist_init)
920 call spec_file_read_scenario(file, gas_data, aero_data, scenario)
921 call spec_file_read_env_state(file, env_state)
924 run_exact_opt%do_coagulation)
925 if (run_exact_opt%do_coagulation)
then
926 call spec_file_read_coag_kernel_type(file, &
927 run_exact_opt%coag_kernel_type)
942 call run_exact(bin_grid, scenario, env_state, aero_data, &
943 aero_dist_init, gas_data, run_exact_opt)
947 end subroutine partmc_exact
952 subroutine partmc_sect(file)
965 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
1055 call spec_file_read_radius_bin_grid(file, bin_grid)
1059 call spec_file_read_gas_data(sub_file, gas_data)
1064 call spec_file_read_aero_data(sub_file, aero_data)
1067 call spec_file_read_fractal(file, aero_data%fractal)
1071 call spec_file_read_aero_dist(sub_file, aero_data, aero_dist_init)
1074 call spec_file_read_scenario(file, gas_data, aero_data, scenario)
1075 call spec_file_read_env_state(file, env_state)
1078 run_sect_opt%do_coagulation)
1079 if (run_sect_opt%do_coagulation)
then
1080 call spec_file_read_coag_kernel_type(file, &
1081 run_sect_opt%coag_kernel_type)
1096 call run_sect(bin_grid, gas_data, aero_data, aero_dist_init, scenario, &
1097 env_state, run_sect_opt)
1101 end subroutine partmc_sect