24 #ifdef PMC_USE_QUADPACK
25 use quadpack_double,
only: dqagse
49 real(kind=
dp) :: z_ref = 20.0d0
51 real(kind=
dp) :: u_mean = 5.0d0
54 real(kind=
dp) :: z_rough = 0.8d0
56 real(kind=
dp) :: a = 2.0d0 / 1000.0d0
58 real(kind=
dp) :: alpha = 1.0d0
60 real(kind=
dp) :: eps_0 = 3.0d0
62 real(kind=
dp) :: gamma = 0.56d0
64 real(kind=
dp) :: c_b = 1.0d0
66 real(kind=
dp) :: c_in = 0.5d0
68 real(kind=
dp) :: c_im = 1.0d0
70 real(kind=
dp) :: nu = 2.0d0
72 real(kind=
dp) :: beta = 2.0d0
88 real(kind=
dp),
allocatable :: temp_time(:)
90 real(kind=
dp),
allocatable :: temp(:)
93 real(kind=
dp),
allocatable :: pressure_time(:)
95 real(kind=
dp),
allocatable :: pressure(:)
98 real(kind=
dp),
allocatable :: height_time(:)
100 real(kind=
dp),
allocatable :: height(:)
103 real(kind=
dp),
allocatable :: gas_emission_time(:)
105 real(kind=
dp),
allocatable :: gas_emission_rate_scale(:)
110 real(kind=
dp),
allocatable :: gas_dilution_time(:)
112 real(kind=
dp),
allocatable :: gas_dilution_rate(:)
117 real(kind=
dp),
allocatable :: aero_emission_time(:)
119 real(kind=
dp),
allocatable :: aero_emission_rate_scale(:)
124 real(kind=
dp),
allocatable :: aero_dilution_time(:)
126 real(kind=
dp),
allocatable :: aero_dilution_rate(:)
131 integer :: loss_function_type
151 real(kind=
dp),
intent(in) :: time
153 env_state%temp =
interp_1d(scenario%temp_time, scenario%temp, time)
154 env_state%pressure =
interp_1d(scenario%pressure_time, &
155 scenario%pressure, time)
156 env_state%height =
interp_1d(scenario%height_time, scenario%height, time)
157 env_state%elapsed_time = time
159 env_state%solar_zenith_angle = 0d0
174 real(kind=
dp),
intent(in) :: time
177 real(kind=
dp) :: pmv_old, pmv_new
179 real(kind=
dp) :: pressure_old
181 real(kind=
dp) :: temp_old
187 pressure_old = env_state%pressure
188 temp_old = env_state%temp
190 env_state%temp =
interp_1d(scenario%temp_time, scenario%temp, time)
191 env_state%pressure =
interp_1d(scenario%pressure_time, &
192 scenario%pressure, time)
194 pmv_new = pmv_old * env_state%pressure / pressure_old
197 env_state%height =
interp_1d(scenario%height_time, scenario%height, time)
198 env_state%elapsed_time = time
242 old_env_state, gas_data, gas_state)
247 real(kind=
dp),
intent(in) :: delta_t
257 real(kind=
dp) :: emission_rate_scale, dilution_rate, p
261 if (
size(scenario%gas_emission) > 0)
then
263 scenario%gas_emission_time, scenario%gas_emission_rate_scale, &
264 env_state%elapsed_time, emissions, emission_rate_scale)
266 p = emission_rate_scale * delta_t / env_state%height
272 scenario%gas_dilution_time, scenario%gas_dilution_rate, &
273 env_state%elapsed_time, background, dilution_rate)
274 p = exp(- dilution_rate * delta_t)
275 if (env_state%height > old_env_state%height)
then
276 p = p * old_env_state%height / env_state%height
294 old_env_state, aero_data, aero_state, n_emit, n_dil_in, n_dil_out, &
295 allow_doubling, allow_halving)
300 real(kind=
dp),
intent(in) :: delta_t
310 integer,
intent(out) :: n_emit
312 integer,
intent(out) :: n_dil_in
314 integer,
intent(out) :: n_dil_out
316 logical,
intent(in) :: allow_doubling
318 logical,
intent(in) :: allow_halving
320 real(kind=
dp),
parameter :: sample_timescale = 3600.0d0
321 real(kind=
dp) :: characteristic_factor, sample_timescale_effective
322 real(kind=
dp) :: emission_rate_scale, dilution_rate, p
326 sample_timescale_effective = max(1.0, min(sample_timescale, &
327 env_state%elapsed_time))
328 characteristic_factor = sample_timescale_effective / delta_t
331 if (
size(scenario%aero_emission) > 0)
then
333 scenario%aero_emission_time, scenario%aero_emission_rate_scale, &
334 env_state%elapsed_time, emissions, emission_rate_scale)
335 p = emission_rate_scale * delta_t / env_state%height
337 emissions, p, characteristic_factor, env_state%elapsed_time, &
338 allow_doubling, allow_halving, n_emit)
343 scenario%aero_dilution_time, scenario%aero_dilution_rate, &
344 env_state%elapsed_time, background, dilution_rate)
345 p = exp(- dilution_rate * delta_t)
346 if (env_state%height > old_env_state%height)
then
347 p = p * old_env_state%height / env_state%height
353 aero_data, 1d0 - p, aero_info_dilution)
357 background, 1d0 - p, characteristic_factor, env_state%elapsed_time, &
358 allow_doubling, allow_halving, n_dil_in)
366 call aero_weight_array_scale(aero_state%awa, &
367 old_env_state%inverse_density * (1.0d0 / env_state%inverse_density))
370 call aero_weight_array_scale(aero_state%awa, &
371 old_env_state%temp * env_state%pressure &
372 / (env_state%temp * old_env_state%pressure))
384 old_env_state, bin_grid, aero_data, aero_binned)
389 real(kind=
dp),
intent(in) :: delta_t
399 type(aero_binned_t),
intent(inout) :: aero_binned
401 real(kind=
dp) :: emission_rate_scale, dilution_rate, p
403 type(aero_binned_t) :: emissions_binned, background_binned
407 scenario%aero_emission_time, scenario%aero_emission_rate_scale, &
408 env_state%elapsed_time, emissions, emission_rate_scale)
409 call aero_binned_add_aero_dist(emissions_binned, bin_grid, aero_data, &
411 p = emission_rate_scale * delta_t / env_state%height
412 call aero_binned_add_scaled(aero_binned, emissions_binned, p)
416 scenario%aero_dilution_time, scenario%aero_dilution_rate, &
417 env_state%elapsed_time, background, dilution_rate)
418 call aero_binned_add_aero_dist(background_binned, bin_grid, aero_data, &
420 p = exp(- dilution_rate * delta_t)
421 if (env_state%height > old_env_state%height)
then
422 p = p * old_env_state%height / env_state%height
424 call aero_binned_scale(aero_binned, p)
425 call aero_binned_add_scaled(aero_binned, background_binned, 1d0 - p)
438 real(kind=
dp),
intent(in) :: del_t
442 real(kind=
dp),
intent(in) :: density
446 real(kind=
dp) :: n, d_pg, ln_sigma_g
447 real(kind=
dp) :: m_0_rate, m_3_rate
448 real(kind=
dp) :: m, new_m
449 real(kind=
dp) :: new_n, new_d_pg
456 else if (scenario%loss_function_type == &
461 n = aero_dist%mode(i_mode)%num_conc
465 d_pg = aero_dist%mode(i_mode)%char_radius * 2.0d0
466 ln_sigma_g = aero_dist%mode(i_mode)%log10_std_dev_radius &
471 aero_dist%mode(i_mode), 0.0d0, density, env_state)
472 new_n = n * exp(m_0_rate * del_t)
474 aero_dist%mode(i_mode)%num_conc = new_n
479 aero_dist%mode(i_mode), 3.0d0, density, env_state)
480 m = n * d_pg**3.0d0 * exp((3.0d0**2.0d0) / 2.0d0 &
481 * (ln_sigma_g**2.0d0))
482 new_m = m * exp(m_3_rate * del_t)
485 new_d_pg = (new_m / new_n * exp(-(3.0d0**2.0d0) / 2.0d0 &
486 * (ln_sigma_g**2.0d0)))**(1.0d0/3.0d0)
487 aero_dist%mode(i_mode)%char_radius = new_d_pg / 2.0d0
497 aero_data, env_state)
502 real(kind=
dp),
intent(in) :: vol
504 real(kind=
dp),
intent(in) :: density
523 aero_data, env_state, scenario)
527 aero_data, env_state) &
529 aero_data, env_state)
531 call die_msg(201594391,
"Unknown loss function id: " &
546 real(kind=
dp),
intent(in) :: vol
548 real(kind=
dp),
intent(in) :: density
559 real(kind=
dp) :: density_air
560 real(kind=
dp) :: visc_d, visc_k
561 real(kind=
dp) :: gas_speed, gas_mean_free_path
562 real(kind=
dp) :: knud, cunning
563 real(kind=
dp) :: grav
564 real(kind=
dp) :: r_s, r_a
565 real(kind=
dp) :: diff_p
566 real(kind=
dp) :: von_karman
567 real(kind=
dp) :: st, sc, u_star
568 real(kind=
dp) :: e_b, e_im, e_in, r1
571 drydep_params = scenario%drydep
576 density_air = (
const%air_molec_weight * env_state%pressure) &
577 / (
const%univ_gas_const * env_state%temp)
579 visc_d = 1.8325d-5 * (416.16 / (env_state%temp + 120.0d0)) &
580 * (env_state%temp / 296.16)**1.5d0
582 visc_k = visc_d / density_air
584 gas_speed = sqrt((8.0d0 *
const%boltzmann * env_state%temp &
587 gas_mean_free_path = (2.0d0 * visc_d) / (density_air * gas_speed)
589 knud = (2.0d0 * gas_mean_free_path) / d_p
591 cunning = 1.0d0 + knud * (1.257d0 + 0.4d0 * exp(-1.1d0 / knud))
595 v_s = (density * d_p**2.0d0 * grav * cunning) / (18.0d0 * visc_d)
599 u_star = .4d0 * drydep_params%u_mean &
600 / log(drydep_params%z_ref / drydep_params%z_rough)
601 r_a = (1.0d0 / (.4d0 * u_star)) &
602 * log(drydep_params%z_ref / drydep_params%z_rough)
604 diff_p = (
const%boltzmann * env_state%temp * cunning) &
605 / (3.d0 *
const%pi * visc_d * d_p)
607 e_b = drydep_params%C_B * sc**(-drydep_params%gamma)
611 e_in = drydep_params%C_IN * (d_p / drydep_params%A)**drydep_params%nu
614 st = (v_s * u_star) / (grav * drydep_params%A)
615 e_im = drydep_params%C_IM * (st &
616 / (drydep_params%alpha + st))**drydep_params%beta
622 r_s = 1.0d0 / (drydep_params%eps_0 * u_star * (e_b + e_in + e_im) * r1)
625 v_d = v_s + (1.0d0 / (r_a + r_s + r_a * r_s * v_s))
637 aero_mode, moment, density, env_state)
642 type(aero_mode_t),
intent(in) :: aero_mode
644 real(kind=
dp),
intent(in) :: moment
646 real(kind=
dp),
intent(in) :: density
650 real(kind=
dp) :: v_d_hat, v_g_hat
651 real(kind=
dp) :: v_g_bar
652 real(kind=
dp) :: d_pg, ln_sigma_g
653 real(kind=
dp) :: density_air
654 real(kind=
dp) :: visc_d, visc_k
655 real(kind=
dp) :: gas_speed, gas_mean_free_path
656 real(kind=
dp) :: knud
657 real(kind=
dp) :: d_bar, d_hat
658 real(kind=
dp) :: st, sc
659 real(kind=
dp) :: u_star
660 real(kind=
dp) :: r_a, r_s
661 real(kind=
dp) :: e_b, e_in, e_im, r1
664 #ifdef PMC_USE_QUADPACK
667 scenario_integrated_loss_rate_drydep_quadpack( &
668 scenario, aero_mode, moment, density, env_state)
672 drydep_params = scenario%drydep
675 d_pg = aero_mode%char_radius * 2.0d0
677 ln_sigma_g = aero_mode%log10_std_dev_radius / log10(exp(1.0d0))
679 density_air = (
const%air_molec_weight * env_state%pressure) &
680 / (
const%univ_gas_const * env_state%temp)
682 visc_d = 1.8325d-5 * (416.16 / (env_state%temp + 120.0d0)) &
683 * (env_state%temp / 296.16)**1.5d0
685 visc_k = visc_d / density_air
687 gas_speed = sqrt((8.0d0 *
const%boltzmann * env_state%temp &
690 gas_mean_free_path = (2.0d0 * visc_d) / (density_air * gas_speed)
692 knud = (2.0d0 * gas_mean_free_path) / d_pg
694 v_g_bar = (density * d_pg**2.0d0 *
const%std_grav) / (18.0d0 * visc_d)
697 * (exp((4.0d0 * moment + 4.0d0) / 2.0d0 * ln_sigma_g**2.0d0) &
699 * exp((2.0d0 * moment + 1.0d0) / 2.0d0 * ln_sigma_g**2.0d0))
702 u_star = 0.4d0 * drydep_params%u_mean / log(drydep_params%z_ref &
703 / drydep_params%z_rough)
704 r_a = (1.0d0 / (0.4d0 * u_star)) &
705 * log(drydep_params%z_ref / drydep_params%z_rough)
708 d_bar = (
const%boltzmann * env_state%temp) &
709 / (3.0d0 *
const%pi * visc_d * d_pg)
712 * ((exp((-2.0d0 * moment + 1.0d0) / 2.0d0 * ln_sigma_g**2.0d0) &
714 * exp((-4.0d0 * moment + 4.0d0) / 2.0d0 * ln_sigma_g**2.0d0)))
718 e_b = drydep_params%C_B * sc**(-drydep_params%gamma)
721 e_in = drydep_params%C_IN * (d_pg / drydep_params%A)**drydep_params%nu
724 st = (v_g_hat * u_star) / (
const%std_grav * drydep_params%A)
726 e_im = drydep_params%C_IM * (st / (drydep_params%alpha + st)) &
733 r_s = 1.0d0 / (drydep_params%eps_0 * u_star * (e_b + e_in + e_im) * r1)
736 v_d_hat = v_g_hat + (1.0d0 / (r_a + r_s + r_a * r_s * v_g_hat))
745 #ifdef PMC_USE_QUADPACK
746 real(kind=
dp)
function scenario_integrated_loss_rate_drydep_quadpack( &
747 scenario, aero_mode, moment, density, env_state)
752 type(aero_mode_t),
intent(in) :: aero_mode
754 real(kind=
dp),
intent(in) :: moment
756 real(kind=
dp),
intent(in) :: density
760 real(kind=
dp) :: d_pg, ln_sigma_g
761 real(kind=
dp) :: density_air
762 real(kind=
dp) :: visc_d, visc_k
763 real(kind=
dp) :: gas_speed, gas_mean_free_path
765 real(kind=
dp) :: lower, upper, epsabs, epsrel, result, abserr, ref
766 integer :: limit, neval, ier, last
767 real(kind=
dp),
allocatable :: alist(:), blist(:), rlist(:), elist(:)
768 integer,
allocatable :: iord(:)
772 drydep_params = scenario%drydep
775 d_pg = aero_mode%char_radius * 2.0d0
777 ln_sigma_g = aero_mode%log10_std_dev_radius / log10(exp(1.0d0))
779 density_air = (
const%air_molec_weight * env_state%pressure) &
780 / (
const%univ_gas_const * env_state%temp)
782 visc_d = 1.8325d-5 * (416.16 / (env_state%temp + 120.0d0)) &
783 * (env_state%temp / 296.16)**1.5d0
785 visc_k = visc_d / density_air
787 gas_speed = sqrt((8.0d0 *
const%boltzmann * env_state%temp &
790 gas_mean_free_path = (2.0d0 * visc_d) / (density_air * gas_speed)
792 ref = exp(log(d_pg) + moment*ln_sigma_g**2)
793 lower = ref / (exp(ln_sigma_g)*10.0)
794 upper = ref * exp(ln_sigma_g)*10.0
802 allocate(alist(limit), blist(limit), rlist(limit), &
803 elist(limit), iord(limit))
806 call dqagse(dep_vel_integrand, lower, upper, epsabs, epsrel, limit, &
807 result, abserr, neval, ier, alist, blist, rlist, elist, iord, last)
810 "QUADPACK integration failed, error code: " &
813 m_k = d_pg**moment * exp(moment**2 * ln_sigma_g**2 / 2.0d0)
816 scenario_integrated_loss_rate_drydep_quadpack = 1.0d0 / m_k * result &
820 deallocate(alist, blist, rlist, elist, iord)
824 real(kind=
dp)
function dep_vel_integrand(d_p)
825 real(kind=
dp),
intent(in) :: d_p
828 real(kind=
dp) :: v_d, v_s
829 real(kind=
dp) :: knud_local, cunning
830 real(kind=
dp) :: diff_p, sc, st
831 real(kind=
dp) :: u_star, r_a, r_s
832 real(kind=
dp) :: e_b, e_in, e_im, r1
833 real(kind=
dp) :: ln_dp, ln_dp_g, n_ddp
836 knud_local = (2.0d0 * gas_mean_free_path) / d_p
839 cunning = 1.0d0 + knud_local * (1.257d0 + 0.4d0 * exp(-1.1d0 / knud_local))
842 v_s = (density * d_p**2.0d0 *
const%std_grav * cunning) / (18.0d0 * visc_d)
845 u_star = 0.4d0 * drydep_params%u_mean &
846 / log(drydep_params%z_ref / drydep_params%z_rough)
847 r_a = (1.0d0 / (0.4d0 * u_star)) &
848 * log(drydep_params%z_ref / drydep_params%z_rough)
851 diff_p = (
const%boltzmann * env_state%temp * cunning) &
852 / (3.0d0 *
const%pi * visc_d * d_p)
856 e_b = drydep_params%C_B * sc**(-drydep_params%gamma)
857 e_in = drydep_params%C_IN * (d_p / drydep_params%A)**drydep_params%nu
860 st = (v_s * u_star) / (
const%std_grav * drydep_params%A)
861 e_im = drydep_params%C_IM &
862 * (st / (drydep_params%alpha + st))**drydep_params%beta
868 r_s = 1.0d0 / (drydep_params%eps_0 * u_star * (e_b + e_in + e_im) * r1)
871 v_d = v_s + (1.0d0 / (r_a + r_s + r_a * r_s * v_s))
876 n_ddp = (1.0d0/(sqrt(2.0d0 *
const%pi) * d_p * ln_sigma_g)) &
877 * exp(-((ln_dp - ln_dp_g)**2) / (2.0d0 * ln_sigma_g**2))
880 dep_vel_integrand = d_p**moment * v_d * n_ddp
881 end function dep_vel_integrand
882 end function scenario_integrated_loss_rate_drydep_quadpack
890 density, env_state, velocities)
897 real(kind=
dp),
intent(in) :: moment
899 real(kind=
dp),
intent(in) :: density
903 real(kind=
dp),
intent(inout) :: velocities(:)
907 do i_mode = 1,
size(velocities)
909 scenario, aero_dist%mode(i_mode), moment, density, env_state) &
924 real(kind=
dp),
intent(in) :: vol
931 integer,
parameter :: n_sample = 3
933 real(kind=
dp) :: d, d_min, d_max, loss
936 d_min = minval(aero_data%density)
937 d_max = maxval(aero_data%density)
970 integer,
parameter :: n_sample = 3
972 real(kind=
dp),
parameter :: over_scale = 2d0
974 real(kind=
dp) :: v_low, v_high, vol, r, r_max
984 r_max = max(r_max, r)
986 loss_max(b) = r_max * over_scale
1007 real(kind=
dp),
intent(in) :: delta_t
1015 integer :: c, b, s, i_part
1016 real(kind=
dp) :: over_rate, over_prob, rand_real, rand_geom
1023 do i_part = aero_state%apa%n_part, 1, -1
1025 aero_data, aero_state, env_state, i_part, 1d0)
1032 if (.not. aero_state%aero_sorted%removal_rate_bounds_valid)
then
1034 aero_state%aero_sorted%bin_grid, aero_data, env_state, &
1035 aero_state%aero_sorted%removal_rate_max)
1036 aero_state%aero_sorted%removal_rate_bounds_valid = .true.
1039 do c = 1,aero_sorted_n_class(aero_state%aero_sorted)
1040 do b = 1,aero_sorted_n_bin(aero_state%aero_sorted)
1041 over_rate = aero_state%aero_sorted%removal_rate_max(b)
1042 if (delta_t * over_rate <= 0d0) cycle
1043 over_prob = 1d0 - exp(-delta_t * over_rate)
1046 do s = aero_state%aero_sorted%size_class%inverse(b, c)%n_entry, &
1049 aero_state%aero_sorted%size_class%inverse(b, c)%entry(s)
1051 aero_data, aero_state, env_state, i_part, 1d0)
1055 s = aero_state%aero_sorted%size_class%inverse(b, c)%n_entry + 1
1058 if (rand_real <= 0d0)
exit
1059 rand_geom = -log(rand_real) / (delta_t * over_rate) + 1d0
1060 if (rand_geom >= real(s, kind=
dp))
exit
1061 s = s - floor(rand_geom)
1067 aero_state%aero_sorted%size_class%inverse(b, c)%entry(s)
1069 aero_data, aero_state, env_state, i_part, over_prob)
1087 aero_data, aero_state, env_state, i_part, over_prob)
1092 real(kind=
dp),
intent(in) :: delta_t
1100 integer,
intent(in) :: i_part
1102 real(kind=
dp),
intent(in) :: over_prob
1104 real(kind=
dp) :: prob, rate, vol, density
1105 type(aero_info_t) :: aero_info
1107 vol = aero_particle_volume(aero_state%apa%particle(i_part))
1108 density = aero_particle_density(aero_state%apa%particle(i_part), aero_data)
1110 prob = 1d0 - exp(-delta_t * rate)
1112 "particle loss upper bound estimation is too tight: " &
1117 aero_info%id = aero_state%apa%particle(i_part)%id
1118 aero_info%action = aero_info_dilution
1119 aero_info%other_id = 0
1133 integer,
intent(in) :: aero_mode_type
1146 subroutine spec_file_read_scenario(file, gas_data, aero_data, &
1147 read_aero_weight_classes, scenario)
1156 logical,
intent(in) :: read_aero_weight_classes
1160 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
1162 character(len=SPEC_LINE_MAX_VAR_LEN) :: function_name
1163 type(spec_line_t) :: line
1209 scenario%temp_time, scenario%temp)
1216 scenario%pressure_time, scenario%pressure)
1223 scenario%height_time, scenario%height)
1229 call spec_file_read_gas_states_times_rates(sub_file, gas_data, &
1230 scenario%gas_emission_time, scenario%gas_emission_rate_scale, &
1231 scenario%gas_emission)
1237 call spec_file_read_gas_states_times_rates(sub_file, gas_data, &
1238 scenario%gas_dilution_time, scenario%gas_dilution_rate, &
1239 scenario%gas_background)
1245 call spec_file_read_aero_dists_times_rates(sub_file, aero_data, &
1246 read_aero_weight_classes, scenario%aero_emission_time, &
1247 scenario%aero_emission_rate_scale, scenario%aero_emission)
1253 call spec_file_read_aero_dists_times_rates(sub_file, aero_data, &
1254 read_aero_weight_classes, scenario%aero_dilution_time, &
1255 scenario%aero_dilution_rate, scenario%aero_background)
1260 if (trim(function_name) ==
'none')
then
1262 else if (trim(function_name) ==
'constant')
then
1264 else if (trim(function_name) ==
'volume')
then
1266 else if (trim(function_name) ==
'drydep')
then
1270 if (line%name /=
'drydep_params')
then
1271 call warn_msg(735291468,
"using default dry deposition parameters")
1275 call spec_file_read_drydep_params(sub_file, scenario%drydep)
1278 else if (trim(function_name) ==
'chamber')
then
1280 call spec_file_read_chamber(file, scenario%chamber)
1283 "Unknown loss function type: " // trim(function_name))
1286 end subroutine spec_file_read_scenario
1392 subroutine spec_file_read_drydep_params(file, drydep_params)
1446 end subroutine spec_file_read_drydep_params
1456 integer,
intent(in) :: ncid
1458 associate(d => drydep_params)
1459 call pmc_nc_write_real(ncid, d%z_ref,
"drydep_z_ref", unit=
"m")
1460 call pmc_nc_write_real(ncid, d%u_mean,
"drydep_u_mean", &
1462 call pmc_nc_write_real(ncid, d%z_rough,
"drydep_z_rough", unit=
"m")
1463 call pmc_nc_write_real(ncid, d%A,
"drydep_A", unit=
"m")
1464 call pmc_nc_write_real(ncid, d%alpha,
"drydep_alpha", unit=
"1")
1465 call pmc_nc_write_real(ncid, d%eps_0,
"drydep_eps_0", unit=
"1")
1466 call pmc_nc_write_real(ncid, d%gamma,
"drydep_gamma", unit=
"1")
1467 call pmc_nc_write_real(ncid, d%C_B,
"drydep_C_B", unit=
"1")
1468 call pmc_nc_write_real(ncid, d%C_IN,
"drydep_C_IN", unit=
"1")
1469 call pmc_nc_write_real(ncid, d%C_IM,
"drydep_C_IM", unit=
"1")
1470 call pmc_nc_write_real(ncid, d%nu,
"drydep_nu", unit=
"1")
1471 call pmc_nc_write_real(ncid, d%beta,
"drydep_beta", unit=
"1")
1484 integer,
intent(in) :: ncid
1486 associate(d => drydep_params)
1487 call pmc_nc_read_real(ncid, d%z_ref,
"drydep_z_ref")
1488 call pmc_nc_read_real(ncid, d%u_mean,
"drydep_u_mean")
1489 call pmc_nc_read_real(ncid, d%z_rough,
"drydep_z_rough")
1490 call pmc_nc_read_real(ncid, d%A,
"drydep_A")
1491 call pmc_nc_read_real(ncid, d%alpha,
"drydep_alpha")
1492 call pmc_nc_read_real(ncid, d%eps_0,
"drydep_eps_0")
1493 call pmc_nc_read_real(ncid, d%gamma,
"drydep_gamma")
1494 call pmc_nc_read_real(ncid, d%C_B,
"drydep_C_B")
1495 call pmc_nc_read_real(ncid, d%C_IN,
"drydep_C_IN")
1496 call pmc_nc_read_real(ncid, d%C_IM,
"drydep_C_IM")
1497 call pmc_nc_read_real(ncid, d%nu,
"drydep_nu")
1498 call pmc_nc_read_real(ncid, d%beta,
"drydep_beta")
1511 integer :: total_size, i
1530 + pmc_mpi_pack_size_chamber(val%chamber)
1531 if (
allocated(val%gas_emission_time))
then
1532 do i = 1,
size(val%gas_emission)
1533 total_size = total_size &
1534 + pmc_mpi_pack_size_gas_state(val%gas_emission(i))
1537 if (
allocated(val%gas_dilution_time))
then
1538 do i = 1,
size(val%gas_background)
1539 total_size = total_size &
1540 + pmc_mpi_pack_size_gas_state(val%gas_background(i))
1543 if (
allocated(val%aero_emission_time))
then
1544 do i = 1,
size(val%aero_emission)
1545 total_size = total_size &
1546 + pmc_mpi_pack_size_aero_dist(val%aero_emission(i))
1549 if (
allocated(val%aero_dilution_time))
then
1550 do i = 1,
size(val%aero_background)
1551 total_size = total_size &
1552 + pmc_mpi_pack_size_aero_dist(val%aero_background(i))
1566 character,
intent(inout) :: buffer(:)
1568 integer,
intent(inout) :: position
1573 integer :: prev_position, i
1575 prev_position = position
1588 val%aero_emission_rate_scale)
1593 call pmc_mpi_pack_chamber(buffer, position, val%chamber)
1594 if (
allocated(val%gas_emission_time))
then
1595 do i = 1,
size(val%gas_emission)
1596 call pmc_mpi_pack_gas_state(buffer, position, val%gas_emission(i))
1599 if (
allocated(val%gas_dilution_time))
then
1600 do i = 1,
size(val%gas_background)
1601 call pmc_mpi_pack_gas_state(buffer, position, val%gas_background(i))
1604 if (
allocated(val%aero_emission_time))
then
1605 do i = 1,
size(val%aero_emission)
1606 call pmc_mpi_pack_aero_dist(buffer, position, val%aero_emission(i))
1609 if (
allocated(val%aero_dilution_time))
then
1610 do i = 1,
size(val%aero_background)
1611 call pmc_mpi_pack_aero_dist(buffer, position, val%aero_background(i))
1626 character,
intent(inout) :: buffer(:)
1628 integer,
intent(inout) :: position
1633 integer :: prev_position, i
1635 prev_position = position
1644 val%gas_emission_rate_scale)
1649 val%aero_emission_rate_scale)
1654 call pmc_mpi_unpack_chamber(buffer, position, val%chamber)
1655 if (
allocated(val%gas_emission))
deallocate(val%gas_emission)
1656 if (
allocated(val%gas_background))
deallocate(val%gas_background)
1657 if (
allocated(val%aero_emission))
deallocate(val%aero_emission)
1658 if (
allocated(val%aero_background))
deallocate(val%aero_background)
1659 if (
allocated(val%gas_emission_time))
then
1660 allocate(val%gas_emission(
size(val%gas_emission_time)))
1661 do i = 1,
size(val%gas_emission)
1662 call pmc_mpi_unpack_gas_state(buffer, position, val%gas_emission(i))
1665 if (
allocated(val%gas_dilution_time))
then
1666 allocate(val%gas_background(
size(val%gas_dilution_time)))
1667 do i = 1,
size(val%gas_background)
1668 call pmc_mpi_unpack_gas_state(buffer, position, &
1669 val%gas_background(i))
1672 if (
allocated(val%aero_emission_time))
then
1673 allocate(val%aero_emission(
size(val%aero_emission_time)))
1674 do i = 1,
size(val%aero_emission)
1675 call pmc_mpi_unpack_aero_dist(buffer, position, val%aero_emission(i))
1678 if (
allocated(val%aero_dilution_time))
then
1679 allocate(val%aero_background(
size(val%aero_dilution_time)))
1680 do i = 1,
size(val%aero_background)
1681 call pmc_mpi_unpack_aero_dist(buffer, position, &
1682 val%aero_background(i))
1721 character,
intent(inout) :: buffer(:)
1723 integer,
intent(inout) :: position
1728 integer :: prev_position
1730 prev_position = position
1755 character,
intent(inout) :: buffer(:)
1757 integer,
intent(inout) :: position
1762 integer :: prev_position
1764 prev_position = position