Go to the documentation of this file.
37 real(kind=
dp) :: magnitude
39 real(kind=
dp) :: exponent
52 aero_weight%magnitude = 1d0
65 real(kind=
dp),
intent(in) :: factor
67 aero_weight%magnitude = aero_weight%magnitude * factor
81 aero_weight%magnitude =
harmonic_mean(aero_weight%magnitude, &
82 aero_weight_delta%magnitude)
92 aero_weight_to, sample_prop, overwrite_to)
99 real(kind=
dp),
intent(in) :: sample_prop
101 logical,
intent(in),
optional :: overwrite_to
103 real(kind=
dp) :: magnitude_transfer
104 logical :: use_overwrite_to
106 magnitude_transfer = aero_weight_from%magnitude / sample_prop
107 aero_weight_from%magnitude =
harmonic_mean(aero_weight_from%magnitude, &
108 - magnitude_transfer)
109 use_overwrite_to = .false.
110 if (
present(overwrite_to))
then
111 if (overwrite_to)
then
112 use_overwrite_to = .true.
115 if (use_overwrite_to)
then
116 aero_weight_to%magnitude = magnitude_transfer
118 aero_weight_to%magnitude =
harmonic_mean(aero_weight_to%magnitude, &
132 real(kind=
dp),
intent(in) :: radius
140 * radius**aero_weight%exponent
142 call die_msg(700421478,
"unknown aero_weight type: " &
175 real(kind=
dp),
intent(in) :: num_conc
179 call die_msg(545688537,
"cannot invert weight type 'none'")
182 call assert_msg(902242996, aero_weight%exponent /= 0d0, &
183 "cannot invert weight with zero exponent")
185 = exp(log(num_conc / aero_weight%magnitude) / aero_weight%exponent)
187 call die_msg(307766845,
"unknown aero_weight type: " &
206 call assert(853998284, aero_weight%exponent == 0d0)
209 call assert(829651126, aero_weight%exponent == -3d0)
219 monotone_increasing, monotone_decreasing)
224 logical,
intent(out) :: monotone_increasing
226 logical,
intent(out) :: monotone_decreasing
232 monotone_increasing = .true.
233 monotone_decreasing = .true.
235 if (aero_weight%exponent < 0d0)
then
236 monotone_increasing = .false.
238 if (aero_weight%exponent > 0d0)
then
239 monotone_decreasing = .false.
243 monotone_increasing = .false.
251 subroutine spec_file_read_aero_weight(file, aero_weight)
258 character(len=SPEC_LINE_MAX_VAR_LEN) :: weight_type
293 aero_weight%magnitude = 0d0
294 if (trim(weight_type) ==
'none')
then
296 elseif (trim(weight_type) ==
'power')
then
299 elseif (trim(weight_type) ==
'mfa')
then
301 aero_weight%exponent = -3d0
304 // trim(weight_type))
307 end subroutine spec_file_read_aero_weight
330 character,
intent(inout) :: buffer(:)
332 integer,
intent(inout) :: position
337 integer :: prev_position
339 prev_position = position
355 character,
intent(inout) :: buffer(:)
357 integer,
intent(inout) :: position
362 integer :: prev_position
364 prev_position = position
Single aerosol particle data structure.
integer, parameter aero_weight_type_none
Type code for no (or flat) weighting.
Wrapper functions for MPI.
elemental subroutine aero_weight_combine(aero_weight, aero_weight_delta)
Combine aero_weight_delta into aero_weight with a harmonic mean.
The aero_weight_t structure and associated subroutines.
integer function pmc_mpi_pack_size_real(val)
Determines the number of bytes required to pack the given value.
The aero_particle_t structure and associated subroutines.
elemental subroutine aero_weight_scale(aero_weight, factor)
Scale the weight by the given fraction, so new_weight = old_weight * factor.
subroutine die_msg(code, error_msg)
Error immediately.
Wrapper functions for NetCDF. These all take a NetCDF ncid in data mode and return with it again in d...
integer, parameter dp
Kind of a double precision real number.
integer function pmc_mpi_pack_size_aero_weight(val)
Determines the number of bytes required to pack the given value.
Reading formatted text input.
subroutine pmc_mpi_pack_real(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
An input file with extra data for printing messages.
subroutine aero_weight_check_valid_exponent(aero_weight)
Ensures that a weight function exponent is valid.
elemental real(kind=dp) function harmonic_mean(x1, x2)
Compute the harmonic mean of two numbers.
subroutine spec_file_read_real(file, name, var)
Read a real number from a spec file that must have the given name.
integer, parameter aero_weight_type_power
Type code for power function weighting.
character(len=pmc_util_convert_string_len) function integer_to_string(val)
Convert an integer to a string format.
subroutine assert_msg(code, condition_ok, error_msg)
Errors unless condition_ok is true.
integer, parameter aero_weight_type_mfa
Type code for MFA weighting.
real(kind=dp) function aero_weight_num_conc_at_radius(aero_weight, radius)
Compute the number concentration at a given radius (m^{-3}).
integer, parameter aero_weight_type_invalid
Type code for an undefined or invalid weighting.
elemental subroutine aero_weight_shift(aero_weight_from, aero_weight_to, sample_prop, overwrite_to)
Adjust source and destination weights to reflect moving sample_prop proportion of particles from aero...
subroutine pmc_mpi_pack_aero_weight(buffer, position, val)
Packs the given value into the buffer, advancing position.
An aerosol size distribution weighting function.
Random number generators.
Aerosol material properties and associated data.
subroutine pmc_mpi_unpack_integer(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
elemental subroutine aero_weight_normalize(aero_weight)
Sets the aero_weight to a non-zero normalized value.
subroutine aero_weight_check_monotonicity(aero_weight, monotone_increasing, monotone_decreasing)
Determine whether a weight function is monotone increasing, monotone decreasing, or neither.
Common utility subroutines.
subroutine spec_file_die_msg(code, file, msg)
Exit with an error message containing filename and line number.
elemental real(kind=dp) function aero_particle_radius(aero_particle, aero_data)
Total radius of the particle (m).
subroutine spec_file_read_string(file, name, var)
Read a string from a spec file that must have a given name.
integer function pmc_mpi_pack_size_integer(val)
Determines the number of bytes required to pack the given value.
subroutine pmc_mpi_pack_integer(buffer, position, val)
Packs the given value into the buffer, advancing position.
The aero_data_t structure and associated subroutines.
subroutine pmc_mpi_unpack_aero_weight(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine pmc_mpi_unpack_real(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
real(kind=dp) function aero_weight_num_conc(aero_weight, aero_particle, aero_data)
Compute the number concentration for a particle (m^{-3}).
real(kind=dp) function aero_weight_radius_at_num_conc(aero_weight, num_conc)
Compute the radius at a given number concentration (m). Inverse of aero_weight_num_conc_at_radius().