52 integer,
intent(in) :: n_group
54 integer,
intent(in) :: n_class
56 if (
allocated(aero_weight_array%weight))
then
57 deallocate(aero_weight_array%weight)
59 allocate(aero_weight_array%weight(n_group, n_class))
71 integer,
intent(in) :: n_class
75 aero_weight_array%weight%magnitude = 1d0
76 aero_weight_array%weight%exponent = 0d0
89 integer,
intent(in) :: n_class
91 real(kind=
dp),
intent(in) :: exponent
95 aero_weight_array%weight%magnitude = 1d0
96 aero_weight_array%weight%exponent = exponent
108 integer,
intent(in) :: n_class
112 aero_weight_array%weight(1, :)%magnitude = 1d0
113 aero_weight_array%weight(1, :)%exponent = 0d0
115 aero_weight_array%weight(2, :)%magnitude = 1d0
116 aero_weight_array%weight(2, :)%exponent = -3d0
165 real(kind=
dp),
intent(in) :: factor
176 aero_weight_array_delta)
184 aero_weight_array_delta%weight)
194 aero_weight_array_to, sample_prop, overwrite_to)
201 real(kind=
dp),
intent(in) :: sample_prop
203 logical,
intent(in),
optional :: overwrite_to
206 aero_weight_array_to%weight, sample_prop, overwrite_to)
214 aero_particle, aero_data)
224 aero_weight_array%weight(aero_particle%weight_group, &
225 aero_particle%weight_class), aero_particle, aero_data)
233 aero_weight_array, i_class, radius)
238 integer,
intent(in) :: i_class
240 real(kind=
dp),
intent(in) :: radius
243 real(kind=
dp) :: num_conc(
size(aero_weight_array%weight, 1))
245 do i_group = 1,
size(aero_weight_array%weight, 1)
247 aero_weight_array%weight(i_group, i_class), radius)
258 aero_particle, aero_data)
268 aero_weight_array, aero_particle%weight_class, &
281 integer :: i_group, i_class
284 do i_group = 1,
size(aero_weight_array%weight, 1)
285 do i_class = 1,
size(aero_weight_array%weight, 2)
287 aero_weight_array%weight(i_group, i_class))
291 if (all(abs(sum(aero_weight_array%weight%exponent, 1)) &
292 < 1d-20 * sum(abs(aero_weight_array%weight%exponent), 1)))
then
305 monotone_increasing, monotone_decreasing)
310 logical,
intent(out) :: monotone_increasing
312 logical,
intent(out) :: monotone_decreasing
314 integer :: i_group, i_class
315 logical :: mono_increasing_array(size(aero_weight_array%weight, 1), &
316 size(aero_weight_array%weight, 2))
317 logical :: mono_decreasing_array(size(aero_weight_array%weight, 1), &
318 size(aero_weight_array%weight, 2))
320 do i_group = 1,
size(aero_weight_array%weight, 1)
321 do i_class = 1,
size(aero_weight_array%weight, 2)
323 aero_weight_array%weight(i_group, i_class), &
324 mono_increasing_array(i_group, i_class), &
325 mono_decreasing_array(i_group, i_class))
329 monotone_increasing = all(mono_increasing_array)
330 monotone_decreasing = all(mono_decreasing_array)
339 radius_1, radius_2, num_conc_min, num_conc_max)
344 integer,
intent(in) :: i_class
346 real(kind=
dp),
intent(in) :: radius_1
348 real(kind=
dp),
intent(in) :: radius_2
350 real(kind=
dp),
intent(out) :: num_conc_min
352 real(kind=
dp),
intent(out) :: num_conc_max
354 real(kind=
dp) :: num_conc_1, num_conc_2
355 logical :: monotone_increasing, monotone_decreasing
358 monotone_increasing, monotone_decreasing)
359 call assert(857727714, monotone_increasing .or. monotone_decreasing)
365 num_conc_min = min(num_conc_1, num_conc_2)
366 num_conc_max = max(num_conc_1, num_conc_2)
380 integer,
intent(in) :: i_class
382 real(kind=
dp),
intent(in) :: radius
384 real(kind=
dp) :: comp_vols(
size(aero_weight_array%weight, 1))
387 do i_group = 1,
size(aero_weight_array%weight, 1)
389 aero_weight_array%weight(i_group, i_class), radius)
405 integer :: i_group, i_class
407 do i_group = 1,
size(aero_weight_array%weight, 1)
408 do i_class = 1,
size(aero_weight_array%weight, 2)
409 call spec_file_read_aero_weight(file, &
410 aero_weight_array%weight(i_group, i_class))
424 integer :: i_group, i_class, total_size
425 logical :: is_allocated
428 is_allocated =
allocated(val%weight)
430 if (is_allocated)
then
431 total_size = total_size &
434 do i_group = 1,
size(val%weight, 1)
435 do i_class = 1,
size(val%weight, 2)
436 total_size = total_size &
451 character,
intent(inout) :: buffer(:)
453 integer,
intent(inout) :: position
458 integer :: prev_position, i_group, i_class
459 logical :: is_allocated
461 prev_position = position
462 is_allocated =
allocated(val%weight)
464 if (is_allocated)
then
467 do i_group = 1,
size(val%weight, 1)
468 do i_class = 1,
size(val%weight, 2)
470 val%weight(i_group, i_class))
486 character,
intent(inout) :: buffer(:)
488 integer,
intent(inout) :: position
493 integer :: prev_position, n_group, n_class, i_group, i_class
494 logical :: is_allocated
496 prev_position = position
498 if (is_allocated)
then
502 do i_group = 1,
size(val%weight, 1)
503 do i_class = 1,
size(val%weight, 2)
505 val%weight(i_group, i_class))
509 if (
allocated(val%weight))
then
510 deallocate(val%weight)
525 ncid, dimid_aero_weight_group)
530 integer,
intent(in) :: ncid
532 integer,
intent(out) :: dimid_aero_weight_group
534 integer :: status, i_group, n_group
535 integer :: varid_aero_weight_group
536 integer :: aero_weight_group_centers(size(aero_weight_array%weight, 1))
539 status = nf90_inq_dimid(ncid,
"aero_weight_group", dimid_aero_weight_group)
540 if (status == nf90_noerr)
return
546 n_group =
size(aero_weight_array%weight, 1)
548 call pmc_nc_check(nf90_def_dim(ncid,
"aero_weight_group", n_group, &
549 dimid_aero_weight_group))
550 call pmc_nc_check(nf90_def_var(ncid,
"aero_weight_group", nf90_int, &
551 dimid_aero_weight_group, varid_aero_weight_group))
552 call pmc_nc_check(nf90_put_att(ncid, varid_aero_weight_group, &
553 "description",
"dummy dimension variable (no useful value)"))
557 do i_group = 1,n_group
558 aero_weight_group_centers(i_group) = i_group
560 call pmc_nc_check(nf90_put_var(ncid, varid_aero_weight_group, &
561 aero_weight_group_centers))
571 ncid, dimid_aero_weight_class)
576 integer,
intent(in) :: ncid
578 integer,
intent(out) :: dimid_aero_weight_class
580 integer :: status, i_class, n_class
581 integer :: varid_aero_weight_class
582 integer :: aero_weight_class_centers(size(aero_weight_array%weight, 2))
585 status = nf90_inq_dimid(ncid,
"aero_weight_class", dimid_aero_weight_class)
586 if (status == nf90_noerr)
return
592 n_class =
size(aero_weight_array%weight, 2)
594 call pmc_nc_check(nf90_def_dim(ncid,
"aero_weight_class", n_class, &
595 dimid_aero_weight_class))
596 call pmc_nc_check(nf90_def_var(ncid,
"aero_weight_class", nf90_int, &
597 dimid_aero_weight_class, varid_aero_weight_class))
598 call pmc_nc_check(nf90_put_att(ncid, varid_aero_weight_class, &
599 "description",
"dummy dimension variable (no useful value)"))
603 do i_class = 1,n_class
604 aero_weight_class_centers(i_class) = i_class
606 call pmc_nc_check(nf90_put_var(ncid, varid_aero_weight_class, &
607 aero_weight_class_centers))
614 subroutine aero_weight_array_output_netcdf(aero_weight_array, ncid)
619 integer,
intent(in) :: ncid
621 integer :: dimid_aero_weight_group, dimid_aero_weight_class
644 dimid_aero_weight_group)
646 dimid_aero_weight_class)
650 (/ dimid_aero_weight_group, dimid_aero_weight_class /), &
651 description=
"type of each aerosol weighting function: 0 = invalid, " &
652 //
"1 = none (w(D) = 1), 2 = power (w(D) = (D/D_0)^alpha), " &
653 //
"3 = MFA (mass flow) (w(D) = (D/D_0)^(-3))")
655 "weight_magnitude", &
656 (/ dimid_aero_weight_group, dimid_aero_weight_class /), &
658 description=
"magnitude for each weighting function")
661 (/ dimid_aero_weight_group, dimid_aero_weight_class /), unit=
"1", &
662 description=
"exponent alpha for the power weight_type, " &
663 //
"set to -3 for MFA, and zero otherwise")
665 end subroutine aero_weight_array_output_netcdf
675 integer,
intent(in) :: ncid
677 integer :: dimid_aero_weight_group, dimid_aero_weight_class, n_group
679 character(len=1000) :: name
680 integer,
allocatable ::
type(:, :)
681 real(kind=
dp),
allocatable :: magnitude(:, :), exponent(:, :)
683 call pmc_nc_check(nf90_inq_dimid(ncid,
"aero_weight_group", &
684 dimid_aero_weight_group))
685 call pmc_nc_check(nf90_inq_dimid(ncid,
"aero_weight_class", &
686 dimid_aero_weight_class))
688 dimid_aero_weight_group, name, n_group))
690 dimid_aero_weight_class, name, n_class))
691 call assert(719221386, n_group < 1000)
692 call assert(520105999, n_class < 1000)
698 call assert(309191498,
size(magnitude) ==
size(type))
699 call assert(588649520,
size(magnitude) ==
size(exponent))
703 aero_weight_array%weight%type =
type
704 aero_weight_array%weight%magnitude = magnitude
705 aero_weight_array%weight%exponent = exponent