34 real(kind=
dp) :: t_max
36 real(kind=
dp) :: del_t
38 real(kind=
dp) :: t_output
40 real(kind=
dp) :: t_progress
43 logical :: do_aero_dilution
45 integer :: coag_kernel_type
47 logical :: do_coagulation
49 logical :: do_camp_chem
53 logical :: do_condensation
59 logical :: do_nucleation
61 logical :: do_immersion_freezing
63 character(len=300) :: prefix
65 character(len=PMC_UUID_LEN) :: uuid
73 subroutine run_sect(bin_grid, gas_data, aero_data, aero_dist, &
74 scenario, env_state, run_sect_opt)
92 integer ima(bin_grid_size(bin_grid),bin_grid_size(bin_grid))
93 real(kind=
dp) g(bin_grid_size(bin_grid)), r(bin_grid_size(bin_grid))
94 real(kind=
dp) e(bin_grid_size(bin_grid))
95 real(kind=
dp) k_bin(bin_grid_size(bin_grid),bin_grid_size(bin_grid))
96 real(kind=
dp) ck(bin_grid_size(bin_grid),bin_grid_size(bin_grid))
97 real(kind=
dp) ec(bin_grid_size(bin_grid),bin_grid_size(bin_grid))
98 real(kind=
dp) taug(bin_grid_size(bin_grid)), taup(bin_grid_size(bin_grid))
99 real(kind=
dp) taul(bin_grid_size(bin_grid)), tauu(bin_grid_size(bin_grid))
100 real(kind=
dp) prod(bin_grid_size(bin_grid)), ploss(bin_grid_size(bin_grid))
101 real(kind=
dp) time, last_output_time, last_progress_time
106 integer i, j, i_time, num_t, i_summary
107 logical do_output, do_progress
110 "del_t", run_sect_opt%del_t)
112 "del_t", run_sect_opt%del_t)
114 "del_t", run_sect_opt%del_t)
123 'run_sect() can only use one aerosol species')
130 do i = 1,bin_grid_size(bin_grid)
131 r(i) = bin_grid%centers(i) * 1d6
133 * aero_data%density(1) * 1d6
140 call courant(bin_grid_size(bin_grid), bin_grid%widths(1), e, ima, c)
143 last_progress_time = 0d0
148 if (run_sect_opt%do_coagulation)
then
149 call bin_kernel(bin_grid_size(bin_grid), bin_grid%centers, aero_data, &
150 run_sect_opt%coag_kernel_type, env_state, k_bin)
152 do i = 1,bin_grid_size(bin_grid)
153 do j = 1,bin_grid_size(bin_grid)
154 ck(i,j) = ck(i,j) * 1d6
159 do i = 1,bin_grid_size(bin_grid)
160 do j = 1,bin_grid_size(bin_grid)
161 ck(i,j) = ck(i,j) * run_sect_opt%del_t * bin_grid%widths(i)
167 call check_event(time, run_sect_opt%del_t, run_sect_opt%t_output, &
168 last_output_time, do_output)
171 aero_binned, gas_data, gas_state, env_state, scenario, i_summary, &
172 time, run_sect_opt%t_output, run_sect_opt%uuid)
176 num_t = nint(run_sect_opt%t_max / run_sect_opt%del_t)
179 if (run_sect_opt%do_coagulation)
then
180 g = aero_binned%vol_conc(:,1) * aero_data%density(1)
181 call coad(bin_grid_size(bin_grid), run_sect_opt%del_t, taug, taup, &
182 taul, tauu, prod, ploss, c, ima, g, r, e, ck, ec)
183 aero_binned%vol_conc(:,1) = g / aero_data%density(1)
184 aero_binned%num_conc = aero_binned%vol_conc(:,1) &
188 time = run_sect_opt%t_max * real(i_time, kind=
dp) &
189 / real(num_t, kind=
dp)
191 old_env_state = env_state
194 env_state, old_env_state, gas_data, gas_state)
196 env_state, old_env_state, bin_grid, aero_data, &
197 run_sect_opt%do_aero_dilution, aero_binned)
200 call check_event(time, run_sect_opt%del_t, run_sect_opt%t_output, &
201 last_output_time, do_output)
203 i_summary = i_summary + 1
205 aero_binned, gas_data, gas_state, env_state, scenario, &
206 i_summary, time, run_sect_opt%t_output, run_sect_opt%uuid)
210 call check_event(time, run_sect_opt%del_t, run_sect_opt%t_progress, &
211 last_progress_time, do_progress)
212 if (do_progress)
then
213 write(*,
'(a6,a8)')
'step',
'time'
214 write(*,
'(i6,f8.1)') i_time, time
224 bin_grid, gas_data, env_state, aero_dist_init, scenario)
243 character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
245 type(spec_line_t) :: line
254 call spec_file_read_radius_bin_grid(file, bin_grid)
257 run_sect_opt%do_camp_chem)
258 if (run_sect_opt%do_camp_chem)
then
260 "sectional run does not support CAMP chemistry")
264 if (run_sect_opt%do_tchem)
then
266 "sectional run does not support TChem chemistry")
271 call spec_file_read_gas_data(sub_file, gas_data)
276 call spec_file_read_aero_data(sub_file, aero_data)
279 call spec_file_read_fractal(file, aero_data%fractal)
283 call spec_file_read_aero_dist(sub_file, aero_data, .false., aero_dist_init)
286 call spec_file_read_scenario(file, gas_data, aero_data, .false., scenario)
290 "sectional run only supports loss_function none or drydep")
291 call spec_file_read_env_state(file, env_state)
294 run_sect_opt%do_aero_dilution = .true.
297 if (line%name ==
'do_aero_dilution')
then
299 run_sect_opt%do_aero_dilution)
302 "do_aero_dilution is only allowed with loss_function drydep")
307 run_sect_opt%do_coagulation)
308 if (run_sect_opt%do_coagulation)
then
309 call spec_file_read_coag_kernel_type(file, &
310 run_sect_opt%coag_kernel_type)
313 env_state%additive_kernel_coefficient)
320 run_sect_opt%do_condensation)
321 if (run_sect_opt%do_condensation)
then
323 "sectional run does not support condensation")
327 if (run_sect_opt%do_mosaic)
then
329 "sectional run does not support MOSAIC chemistry")
331 if (run_sect_opt%do_optical)
then
333 "sectional run does not support optical properties calculation")
336 run_sect_opt%do_optical = .false.
340 run_sect_opt%do_nucleation)
341 if (run_sect_opt%do_nucleation)
then
343 "sectional run does not support nucleation")
347 run_sect_opt%do_immersion_freezing)
348 if (run_sect_opt%do_immersion_freezing)
then
350 "sectional run does not support immersion freezing")
368 subroutine coad(n_bin, dt, taug, taup, taul, tauu, prod, ploss, &
369 c, ima, g, r, e, ck, ec)
373 real(kind=
dp) taug(n_bin)
374 real(kind=
dp) taup(n_bin)
375 real(kind=
dp) taul(n_bin)
376 real(kind=
dp) tauu(n_bin)
377 real(kind=
dp) prod(n_bin)
378 real(kind=
dp) ploss(n_bin)
379 real(kind=
dp) c(n_bin,n_bin)
380 integer ima(n_bin,n_bin)
381 real(kind=
dp) g(n_bin)
382 real(kind=
dp) r(n_bin)
383 real(kind=
dp) e(n_bin)
384 real(kind=
dp) ck(n_bin,n_bin)
385 real(kind=
dp) ec(n_bin,n_bin)
387 real(kind=
dp),
parameter :: gmin = 1d-60
389 integer i, i0, i1, j, k, kp
390 real(kind=
dp) x0, gsi, gsj, gsk, gk, x1, flux
398 do i0 = 1,(n_bin - 1)
399 if (g(i0) .gt. gmin)
goto 2000
402 do i1 = (n_bin - 1),1,-1
403 if (g(i1) .gt. gmin)
goto 2010
412 x0 = ck(i,j) * g(i) * g(j)
413 x0 = min(x0, g(i) * e(j))
415 if (j .ne. k) x0 = min(x0, g(j) * e(i))
421 ploss(i) = ploss(i) + gsi
422 ploss(j) = ploss(j) + gsj
429 if (gk .gt. gmin)
then
430 x1 = log(g(kp) / gk + 1d-60)
431 flux = gsk / x1 * (exp(0.5d0 * x1) &
432 - exp(x1 * (0.5d0 - c(i,j))))
437 prod(k) = prod(k) + gsk - flux
438 prod(kp) = prod(kp) + flux
449 subroutine courant(n_bin, log_width, e, ima, c)
452 integer,
intent(in) :: n_bin
454 real(kind=
dp),
intent(in) :: log_width
456 real(kind=
dp),
intent(in) :: e(n_bin)
458 integer,
intent(out) :: ima(n_bin,n_bin)
460 real(kind=
dp),
intent(out) :: c(n_bin,n_bin)
480 if (c(i,j) .lt. 1d0 - 1d-08)
then
482 c(i,j) = log(x0 / e(k-1)) / (3d0 * log_width)
487 ima(i,j) = min(n_bin - 1, kk)
502 integer,
intent(in) :: n_bin
504 real(kind=
dp),
intent(in) :: k(n_bin,n_bin)
506 real(kind=
dp),
intent(out) :: k_smooth(n_bin,n_bin)
508 integer i, j, im, ip, jm, jp
514 jp = min0(j + 1, n_bin)
515 ip = min0(i + 1, n_bin)
516 k_smooth(i,j) = 0.125d0 * (k(i,jm) + k(im,j) &
517 + k(ip,j) + k(i,jp)) &
520 k_smooth(i,j) = 0.5d0 * k_smooth(i,j)