53 allocate(aero_dist%mode(0))
65 integer,
intent(in) :: n_mode
67 integer,
intent(in) :: n_spec
71 aero_dist%n_mode = n_mode
72 allocate(aero_dist%mode(n_mode))
89 do i = 1,aero_dist%n_mode
92 deallocate(aero_dist%mode)
108 if (aero_dist_from%n_mode > 0)
then
109 n_spec =
size(aero_dist_from%mode(1)%vol_frac)
115 do i = 1,aero_dist_from%n_mode
132 do i_mode = 1,aero_dist%n_mode
147 type(aero_weight_t
),
intent(in) :: aero_weight
152 do i_mode = 1,aero_dist%n_mode
172 real(kind=dp),
intent(out) :: num_conc(bin_grid%n_bin)
175 real(kind=dp) :: mode_num_conc(size(num_conc, 1))
178 do i_mode = 1,aero_dist%n_mode
180 aero_data, mode_num_conc)
181 num_conc = num_conc + mode_num_conc
200 real(kind=dp),
intent(out) :: vol_conc(bin_grid%n_bin, aero_data%n_spec)
203 real(kind=dp) :: mode_vol_conc(size(vol_conc, 1), size(vol_conc, 2))
206 do i_mode = 1,aero_dist%n_mode
208 aero_data, mode_vol_conc)
209 vol_conc = vol_conc + mode_vol_conc
223 integer,
intent(in) :: aero_mode_type
226 = any(aero_dist%mode%type == aero_mode_type)
235 rate_list, time, aero_dist, rate)
240 real(kind=dp),
intent(in) :: time_list(size(aero_dist_list))
242 real(kind=dp),
intent(in) :: rate_list(size(aero_dist_list))
244 real(kind=dp),
intent(in) :: time
248 real(kind=dp),
intent(out) :: rate
250 integer :: n, p, n_bin, n_spec, i, i_new
251 real(kind=dp) :: y, alpha
253 n =
size(aero_dist_list)
254 p =
find_1d(n, time_list, time)
274 subroutine spec_file_read_aero_dist(file, aero_data, aero_dist)
283 type(aero_mode_t),
pointer :: new_aero_mode_list(:)
304 call spec_file_read_aero_mode(file, aero_data, aero_mode, eof)
306 aero_dist%n_mode = aero_dist%n_mode + 1
307 allocate(new_aero_mode_list(aero_dist%n_mode))
308 do i = 1,aero_dist%n_mode
312 new_aero_mode_list(aero_dist%n_mode))
313 do i = 1,(aero_dist%n_mode - 1)
315 new_aero_mode_list(i))
318 deallocate(aero_dist%mode)
319 aero_dist%mode => new_aero_mode_list
320 nullify(new_aero_mode_list)
321 call spec_file_read_aero_mode(file, aero_data, aero_mode, eof)
325 end subroutine spec_file_read_aero_dist
331 subroutine spec_file_read_aero_dists_times_rates(file, aero_data, &
332 times, rates, aero_dists)
339 real(kind=dp),
pointer :: times(:)
341 real(kind=dp),
pointer :: rates(:)
345 type(spec_line_t
) :: aero_dist_line
347 integer :: n_time, i_time
348 character(len=SPEC_LINE_MAX_VAR_LEN),
pointer :: names(:)
349 real(kind=dp),
pointer :: data(:,:)
422 if (trim(names(1)) /=
'time')
then
423 call
die_msg(570205795,
'row 1 in ' // trim(file%name) &
424 //
' must start with: time not: ' // trim(names(1)))
426 if (trim(names(2)) /=
'rate')
then
427 call
die_msg(221270915,
'row 2 in ' // trim(file%name) &
428 //
' must start with: rate not: ' // trim(names(1)))
430 n_time =
size(
data, 2)
432 call
die_msg(457229710,
'each line in ' // trim(file%name) &
433 //
' must contain at least one data value')
437 do i_time = 1,
size(aero_dists)
440 deallocate(aero_dists)
443 allocate(aero_dists(n_time))
444 allocate(times(n_time))
445 allocate(rates(n_time))
449 call spec_file_read_aero_dist(aero_dist_file, &
450 aero_data, aero_dists(i_time))
452 times(i_time) =
data(1,i_time)
453 rates(i_time) =
data(2,i_time)
459 end subroutine spec_file_read_aero_dists_times_rates
469 integer :: i, total_size
472 do i = 1,
size(val%mode)
485 character,
intent(inout) :: buffer(:)
487 integer,
intent(inout) :: position
492 integer :: prev_position, i
494 prev_position = position
496 do i = 1,
size(val%mode)
511 character,
intent(inout) :: buffer(:)
513 integer,
intent(inout) :: position
518 integer :: prev_position, i
521 prev_position = position
523 allocate(val%mode(val%n_mode))
524 do i = 1,
size(val%mode)
An input file with extra data for printing messages.
subroutine spec_file_check_line_name(file, line, name)
Check that the name of the line data is as given.
The aero_data_t structure and associated subroutines.
integer function pmc_mpi_pack_size_integer(val)
Determines the number of bytes required to pack the given value.
subroutine die_msg(code, error_msg)
Error immediately.
subroutine aero_dist_interp_1d(aero_dist_list, time_list, rate_list, time, aero_dist, rate)
Determine the current aero_dist and rate by interpolating at the current time with the lists of aero_...
subroutine pmc_mpi_unpack_aero_mode(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
integer function pmc_mpi_pack_size_aero_dist(val)
Determines the number of bytes required to pack the given value.
The aero_dist_t structure and associated subroutines.
subroutine spec_file_open(filename, file)
Open a spec file for reading.
integer function find_1d(n, x_vals, x)
Find the position of a real number in an arbitrary 1D array.
subroutine aero_dist_allocate_size(aero_dist, n_mode, n_spec)
Allocates an aero_dist of the given size.
subroutine aero_mode_vol_conc(aero_mode, bin_grid, aero_data, vol_conc)
Return the binned per-species volume concentration for an aero_mode.
subroutine aero_dist_deallocate(aero_dist)
Free all storage.
Random number generators.
integer function pmc_mpi_pack_size_aero_mode(val)
Determines the number of bytes required to pack the given value.
subroutine spec_file_check_line_length(file, line, length)
Check that the length of the line data is as given.
real(kind=dp) function aero_mode_number(aero_mode, aero_weight)
Return the total number of computational particles for an aero_mode.
subroutine aero_mode_num_conc(aero_mode, bin_grid, aero_data, num_conc)
Return the binned number concentration for an aero_mode.
subroutine pmc_mpi_pack_integer(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine aero_mode_allocate(aero_mode)
Allocates an aero_mode.
real(kind=dp) function aero_mode_total_num_conc(aero_mode)
Returns the total number concentration of a mode. (#/m^3)
subroutine spec_file_read_real_named_array(file, max_lines, names, vals)
Read an array of named lines with real data. All lines must have the same number of data elements...
A complete aerosol distribution, consisting of several modes.
Common utility subroutines.
An aerosol size distribution mode.
subroutine pmc_mpi_unpack_integer(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
real(kind=dp) function aero_dist_total_num_conc(aero_dist)
Returns the total number concentration of a distribution. (#/m^3)
subroutine aero_mode_copy(aero_mode_from, aero_mode_to)
Copy an aero_mode.
Wrapper functions for MPI.
real(kind=dp) function aero_dist_number(aero_dist, aero_weight)
Returns the total number of particles of a distribution.
The aero_mode_t structure and associated subroutines.
1D grid, either logarithmic or linear.
The bin_grid_t structure and associated subroutines.
Reading formatted text input.
subroutine spec_file_close(file)
Close a spec file.
subroutine aero_dist_num_conc(aero_dist, bin_grid, aero_data, num_conc)
Return the binned number concentration for an aero_dist.
subroutine aero_dist_copy(aero_dist_from, aero_dist_to)
Copy an aero_dist.
elemental logical function aero_dist_contains_aero_mode_type(aero_dist, aero_mode_type)
Whether any of the modes are of the given type.
subroutine spec_line_allocate(spec_line)
Allocates memory for a spec_line.
subroutine pmc_mpi_unpack_aero_dist(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine spec_line_deallocate(spec_line)
Frees all storage.
subroutine pmc_mpi_pack_aero_dist(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine pmc_mpi_pack_aero_mode(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine spec_file_read_line_no_eof(file, line)
Read a spec_line from the spec_file. This will always succeed or error out, so should only be called ...
subroutine aero_mode_allocate_size(aero_mode, n_spec)
Allocates an aero_mode of the given size.
Aerosol material properties and associated data.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
subroutine aero_mode_deallocate(aero_mode)
Free all storage.
subroutine aero_dist_allocate(aero_dist)
Allocates an aero_dist.
subroutine aero_dist_vol_conc(aero_dist, bin_grid, aero_data, vol_conc)
Return the binned per-species volume concentration for an aero_dist.