342 integer(kind=i_kind),
intent(in) :: spec_state_id
344 type(
property_t),
pointer :: sections, section, phases
345 integer(kind=i_kind) :: i_section, i_phase, j_phase, k_phase, &
347 integer(kind=i_kind) :: curr_spec_state_id
348 integer(kind=i_kind) :: num_phase, num_bin
349 integer(kind=i_kind) :: n_int_param, n_float_param
350 character(len=:),
allocatable :: key_name, phase_name, sect_type, str_val
351 real(kind=dp) :: min_dp, max_dp, d_log_dp
354 n_int_param = num_int_prop_
355 n_float_param = num_real_prop_
358 key_name =
"modes/bins"
360 this%property_set%get_property_t(key_name, sections), &
361 "Missing sections/bins for modal/binned mass aerosol "// &
362 "representation '"//this%rep_name//
"'")
363 call assert_msg(894962494, sections%size().gt.0,
"No sections or bins "// &
364 "specified for modal/binned mass aerosol representation '"// &
368 allocate(this%section_name(sections%size()))
373 call sections%iter_reset()
374 do i_section = 1, sections%size()
377 call assert(867378489, sections%get_key(key_name))
378 call assert_msg(234513113, len(key_name).gt.0,
"Missing mode/bin "// &
379 "name in modal/binned mass aerosol representation '"// &
381 this%section_name(i_section)%string = key_name
384 call assert_msg(517138327, sections%get_property_t(val=section), &
385 "Invalid structure for mode/bin '"// &
386 this%section_name(i_section)%string// &
387 "' in modal/binned mass aerosol representation '"// &
392 call assert_msg(742404898, section%get_string(key_name, sect_type), &
393 "Missing mode/bin type in mode/bin '"// &
394 this%section_name(i_section)%string// &
395 "' in modal/binned mass aerosol representation '"// &
398 sect_type.eq.
"MODAL".or.sect_type.eq.
"BINNED", &
399 "Invalid mode/bin type '"//sect_type//
"' in mode/bin '"// &
400 this%section_name(i_section)%string// &
401 "' in modal/binned mass aerosol representation '"// &
406 if (sect_type.eq.
"BINNED")
then
409 call assert_msg(824494286, section%get_int(key_name, num_bin), &
410 "Missing number of bins in bin '"// &
411 this%section_name(i_section)%string// &
412 "' in modal/binned mass aerosol representation '"// &
418 n_int_param = n_int_param + 5
422 n_float_param = n_float_param + 3*num_bin
426 call assert_msg(815518058, section%get_property_t(key_name, phases), &
427 "Missing phases for mode '"// &
428 this%section_name(i_section)%string// &
429 "' in modal/binned mass aerosol representation '"// &
433 call assert_msg(772593427, phases%size().gt.0, &
434 "No phases specified for mode '"// &
435 this%section_name(i_section)%string// &
436 "' in modal/binned mass aerosol representation '"// &
438 num_phase = num_phase + phases%size() * num_bin
441 call phases%iter_reset()
442 do i_phase = 1, phases%size()
445 call assert_msg(393427582, phases%get_string(val=phase_name), &
446 "Non-string phase name for mode '"// &
447 this%section_name(i_section)%string// &
448 "' in modal/binned mass aerosol representation '"// &
452 do j_phase = 1,
size(aero_phase_set)
453 if (phase_name.eq.aero_phase_set(j_phase)%val%name())
then
457 n_int_param = n_int_param + 3 * num_bin
460 n_float_param = n_float_param + 2 * num_bin
463 else if (j_phase.eq.
size(aero_phase_set))
then
464 call die_msg(652391420,
"Non-existant aerosol phase '"// &
465 phase_name//
"' specified for mode '"// &
466 this%section_name(i_section)%string// &
467 "' in modal/binned mass aerosol representation '"// &
472 call phases%iter_next()
475 call sections%iter_next()
479 allocate(this%aero_phase(num_phase))
480 allocate(this%aero_phase_is_at_surface(num_phase))
481 allocate(this%phase_state_id(
size(this%aero_phase)))
484 allocate(this%condensed_data_int(n_int_param))
485 allocate(this%condensed_data_real(n_float_param))
486 this%condensed_data_int(:) = int(0, kind=i_kind)
487 this%condensed_data_real(:) = real(0.0, kind=dp)
488 int_data_size_ = n_int_param
489 real_data_size_ = n_float_param
492 num_section_ = sections%size()
495 this%num_env_params = 2 * num_section_
501 n_int_param = num_int_prop_+2*num_section_+1
502 n_float_param = num_real_prop_+1
503 call sections%iter_reset()
504 do i_section = 1, num_section_
507 mode_int_prop_loc_(i_section) = n_int_param
508 mode_real_prop_loc_(i_section) = n_float_param
511 call assert(394743663, sections%get_property_t(val=section))
515 call assert(667058653, section%get_string(key_name, sect_type))
516 if (sect_type.eq.
"MODAL")
then
517 section_type_(i_section) = modal
518 else if (sect_type.eq.
"BINNED")
then
519 section_type_(i_section) = binned
521 call die_msg(256924433,
"Internal error")
525 num_bins_(i_section) = 1
526 if (section_type_(i_section).eq.binned)
then
528 call assert(315215287, section%get_int(key_name, num_bins_(i_section)))
532 if (section_type_(i_section).eq.modal)
then
536 effective_radius_(i_section,1) = -9999.9
537 number_conc_(i_section,1) = -9999.9
540 else if (section_type_(i_section).eq.binned)
then
543 key_name =
"minimum diameter [m]"
544 call assert_msg(548762180, section%get_real(key_name, min_dp), &
545 "Missing minimum diameter for bin '"// &
546 this%section_name(i_section)%string// &
547 "' in modal/binned mass aerosol representation '"// &
551 key_name =
"maximum diameter [m]"
552 call assert_msg(288632226, section%get_real(key_name, max_dp), &
553 "Missing maximum diameter for bin '"// &
554 this%section_name(i_section)%string// &
555 "' in modal/binned mass aerosol representation '"// &
560 call assert_msg(404761639, section%get_string(key_name, str_val), &
561 "Missing bin scale for bin '"// &
562 this%section_name(i_section)%string// &
563 "' in modal/binned mass aerosol representation '"// &
567 if (str_val.eq.
"LINEAR")
then
568 do i_bin = 1, num_bins_(i_section)
569 bin_dp_(i_section,i_bin) = min_dp + &
570 (i_bin-1) * (max_dp-min_dp)/(num_bins_(i_section)-1)
572 else if (str_val.eq.
"LOG")
then
573 d_log_dp = (log10(max_dp)-log10(min_dp))/(num_bins_(i_section)-1)
574 do i_bin = 1, num_bins_(i_section)
575 bin_dp_(i_section,i_bin) = 10.0d0**( log10(min_dp) + &
576 (i_bin-1) * d_log_dp )
579 call die_msg(236797392,
"Invalid scale specified for bin '"// &
580 this%section_name(i_section)%string// &
581 "' in modal/binned mass aerosol representation '"// &
584 do i_bin = 1, num_bins_(i_section)
586 effective_radius_(i_section,i_bin) = bin_dp_(i_section,i_bin) / 2.0
587 number_conc_(i_section,i_bin) = -9999.9
593 call assert(712411046, section%get_property_t(key_name, phases))
596 num_phase_(i_section) = phases%size()
599 n_int_param = n_int_param + 3
602 n_float_param = n_float_param + 3 * num_bins_(i_section)
605 call phases%iter_reset()
606 do j_phase = 1, phases%size()
609 call assert(775801035, phases%get_string(val=phase_name))
612 do k_phase = 1,
size(aero_phase_set)
613 if (phase_name.eq.aero_phase_set(k_phase)%val%name())
then
616 do i_bin = 1, num_bins_(i_section)
619 this%aero_phase(i_phase) = aero_phase_set(k_phase)
622 this%aero_phase_is_at_surface(i_phase) = .true.
625 this%phase_state_id(i_phase) = curr_spec_state_id
626 phase_state_id_(i_section, j_phase, i_bin) = curr_spec_state_id
629 curr_spec_state_id = curr_spec_state_id + &
630 aero_phase_set(k_phase)%val%size()
633 phase_model_data_id_(i_section, j_phase, i_bin) = k_phase
635 i_phase = i_phase + 1
640 n_int_param = n_int_param + 3*num_bins_(i_section)
643 n_float_param = n_float_param + 2*num_bins_(i_section)
646 else if (k_phase.eq.
size(aero_phase_set))
then
647 call die_msg(652391420,
"Internal error.")
651 call phases%iter_next()
654 call sections%iter_next()
661 call assert(951534966, i_phase-1.eq.num_phase)
662 call assert(951534966, n_int_param.eq.int_data_size_+1)
663 call assert(325387136, n_float_param.eq.real_data_size_+1)
744 character(len=*),
optional,
intent(in) :: phase_name
746 integer(kind=i_kind),
optional,
intent(in) :: tracer_type
748 character(len=*),
optional,
intent(in) ::
spec_name
750 integer(kind=i_kind) :: num_spec, i_spec, j_spec, i_phase, j_phase, &
752 integer(kind=i_kind) :: curr_tracer_type
753 character(len=:),
allocatable :: curr_section_name, curr_phase_name, &
755 type(
string_t),
allocatable :: spec_names(:)
759 do i_phase = 1,
size(this%aero_phase)
762 if (
present(phase_name))
then
763 curr_phase_name = this%aero_phase(i_phase)%val%name()
764 if (phase_name.ne.curr_phase_name) cycle
768 if (
present(
spec_name).or.
present(tracer_type))
then
769 spec_names = this%aero_phase(i_phase)%val%get_species_names()
770 do j_spec = 1,
size(spec_names)
772 this%aero_phase(i_phase)%val%get_species_type( &
773 spec_names(j_spec)%string)
775 if (
spec_name.ne.spec_names(j_spec)%string) cycle
777 if (
present(tracer_type))
then
778 if (tracer_type.ne.curr_tracer_type) cycle
780 num_spec = num_spec + 1
783 num_spec = num_spec + this%aero_phase(i_phase)%val%size()
794 do i_section = 1, num_section_
797 curr_section_name = this%section_name(i_section)%string
800 do j_phase = 1, num_phase_(i_section)
803 curr_phase_name = this%aero_phase(i_phase)%val%name()
806 if (
present(phase_name))
then
807 if (phase_name.ne.curr_phase_name)
then
808 i_phase = i_phase + num_bins_(i_section)
814 spec_names = this%aero_phase(i_phase)%val%get_species_names()
817 do i_bin = 1, num_bins_(i_section)
820 if (num_bins_(i_section).gt.1)
then
821 curr_bin_str = trim(
to_string(i_bin))//
"."
827 num_spec = this%aero_phase(i_phase)%val%size()
828 do j_spec = 1, num_spec
832 if (
spec_name.ne.spec_names(j_spec)%string) cycle
836 if (
present(tracer_type))
then
838 this%aero_phase(i_phase)%val%get_species_type( &
839 spec_names(j_spec)%string)
840 if (tracer_type.ne.curr_tracer_type) cycle
844 unique_names(i_spec)%string = curr_section_name//
"."// &
845 curr_bin_str//curr_phase_name//
'.'// &
846 spec_names(j_spec)%string
852 i_phase = i_phase + 1
856 deallocate(spec_names)