36 real(kind=dp),
pointer :: num_conc(:)
39 real(kind=dp),
pointer :: vol_conc(:,:)
52 allocate(aero_binned%num_conc(0))
53 allocate(aero_binned%vol_conc(0, 0))
65 integer,
intent(in) :: n_bin
68 integer,
intent(in) :: n_spec
70 allocate(aero_binned%num_conc(n_bin))
71 allocate(aero_binned%vol_conc(n_bin, n_spec))
84 deallocate(aero_binned%num_conc)
85 deallocate(aero_binned%vol_conc)
97 aero_binned%num_conc = 0d0
98 aero_binned%vol_conc = 0d0
114 aero_binned%num_conc = aero_binned%num_conc + aero_binned_delta%num_conc
115 aero_binned%vol_conc = aero_binned%vol_conc + aero_binned_delta%vol_conc
131 real(kind=dp),
intent(in) :: alpha
133 aero_binned%num_conc = aero_binned%num_conc &
134 + alpha * aero_binned_delta%num_conc
135 aero_binned%vol_conc = aero_binned%vol_conc &
136 + alpha * aero_binned_delta%vol_conc
152 aero_binned%num_conc = aero_binned%num_conc - aero_binned_delta%num_conc
153 aero_binned%vol_conc = aero_binned%vol_conc - aero_binned_delta%vol_conc
167 real(kind=dp),
intent(in) :: alpha
169 aero_binned%num_conc = aero_binned%num_conc * alpha
170 aero_binned%vol_conc = aero_binned%vol_conc * alpha
182 real(kind=dp),
allocatable,
intent(in) :: alpha_array(:)
186 do i = 1,
size(aero_binned%num_conc)
187 aero_binned%num_conc(i) = alpha_array(i)*aero_binned%num_conc(i)
188 aero_binned%vol_conc(i,:) = alpha_array(i)*aero_binned%vol_conc(i,:)
205 integer :: n_bin, n_spec
207 n_bin =
size(aero_binned_from%vol_conc, 1)
208 n_spec =
size(aero_binned_from%vol_conc, 2)
211 aero_binned_to%num_conc = aero_binned_from%num_conc
212 aero_binned_to%vol_conc = aero_binned_from%vol_conc
222 aero_data, aero_dist)
233 real(kind=dp) :: dist_num_conc(size(aero_binned%num_conc, 1))
234 real(kind=dp) :: dist_vol_conc(size(aero_binned%vol_conc, 1), &
235 size(aero_binned%vol_conc, 2))
241 aero_binned%num_conc = aero_binned%num_conc + dist_num_conc
242 aero_binned%vol_conc = aero_binned%vol_conc + dist_vol_conc
270 character,
intent(inout) :: buffer(:)
272 integer,
intent(inout) :: position
277 integer :: prev_position
279 prev_position = position
296 character,
intent(inout) :: buffer(:)
298 integer,
intent(inout) :: position
303 integer :: prev_position
305 prev_position = position
333 subroutine aero_binned_output_netcdf(aero_binned, ncid, bin_grid, &
339 integer,
intent(in) :: ncid
345 integer :: dimid_aero_diam, dimid_aero_species
346 real(kind=dp) :: mass_conc(bin_grid%n_bin, aero_data%n_spec)
372 do i_bin = 1,bin_grid%n_bin
373 mass_conc(i_bin,:) = aero_binned%vol_conc(i_bin,:) * aero_data%density
377 dimid_aero_diam,
"aerosol diameter", scale=2d0)
381 "aero_number_concentration", (/ dimid_aero_diam /), &
383 long_name=
"aerosol number size concentration distribution", &
384 description=
"logarithmic number size concentration, " &
385 //
"d N(r)/d ln D --- multiply by aero_diam_widths(i) " &
386 //
"and sum over i to compute the total number concentration")
388 "aero_mass_concentration", &
389 (/ dimid_aero_diam, dimid_aero_species /), unit=
"kg/m^3", &
390 long_name=
"aerosol mass size concentration distribution", &
391 description=
"logarithmic mass size concentration per species, " &
392 //
"d M(r,s)/d ln D --- multiply by aero_diam_widths(i) " &
393 //
"and sum over i to compute the total mass concentration of " &
396 end subroutine aero_binned_output_netcdf
435 integer,
intent(in) :: ncid
441 real(kind=dp) :: mass_conc(bin_grid%n_bin, aero_data%n_spec)
449 "aero_number_concentration")
452 do i_bin = 1,bin_grid%n_bin
453 aero_binned%vol_conc(i_bin,:) = mass_conc(i_bin,:) / aero_data%density
subroutine aero_binned_allocate_size(aero_binned, n_bin, n_spec)
Allocate an aero_binned_t of the given size.
subroutine pmc_nc_write_real_1d(ncid, var, name, dimids, dim_name, unit, long_name, standard_name, description)
Write a simple real array to a NetCDF file.
integer function pmc_mpi_pack_size_real_array(val)
Determines the number of bytes required to pack the given value.
The aero_data_t structure and associated subroutines.
subroutine pmc_mpi_pack_real_array_2d(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine pmc_mpi_unpack_aero_binned(buffer, position, val)
Unpack the structure from the buffer and advance position.
The aero_dist_t structure and associated subroutines.
subroutine aero_binned_sub(aero_binned, aero_binned_delta)
Subtract one aero_binned_t structure from another.
The aero_particle_t structure and associated subroutines.
subroutine aero_binned_deallocate(aero_binned)
Free internal memory in an aero_binned_t structure.
subroutine aero_binned_allocate(aero_binned)
Allocate an aero_binned_t.
subroutine bin_grid_netcdf_dim(bin_grid, ncid, dim_name, unit, dimid, long_name, scale)
Write a bin grid dimension to the given NetCDF file if it is not already present and in any case retu...
subroutine pmc_mpi_reduce_avg_real_array(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on the root process...
A complete aerosol distribution, consisting of several modes.
subroutine aero_data_netcdf_dim_aero_species(aero_data, ncid, dimid_aero_species)
Write the aero species dimension to the given NetCDF file if it is not already present and in any cas...
Common utility subroutines.
subroutine pmc_mpi_unpack_real_array(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine aero_binned_add(aero_binned, aero_binned_delta)
Add two aero_binned_t structures together.
subroutine pmc_nc_read_real_1d(ncid, var, name, must_be_present)
Read a simple real array from a NetCDF file.
subroutine pmc_nc_read_real_2d(ncid, var, name, must_be_present)
Read a simple real 2D array from a NetCDF file.
subroutine aero_binned_scale(aero_binned, alpha)
Scale an aero_binned_t by a real number.
Wrapper functions for MPI.
subroutine pmc_mpi_pack_aero_binned(buffer, position, val)
Pack the structure into the buffer and advance position.
integer function pmc_mpi_pack_size_real_array_2d(val)
Determines the number of bytes required to pack the given value.
1D grid, either logarithmic or linear.
The bin_grid_t structure and associated subroutines.
subroutine pmc_mpi_unpack_real_array_2d(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine pmc_nc_write_real_2d(ncid, var, name, dimids, dim_name_1, dim_name_2, unit, long_name, standard_name, description)
Write a simple real 2D array to a NetCDF file.
Reading formatted text input.
subroutine aero_dist_num_conc(aero_dist, bin_grid, aero_data, num_conc)
Return the binned number concentration for an aero_dist.
The aero_binned_t structure and associated subroutines.
subroutine pmc_mpi_reduce_avg_aero_binned(val, val_avg)
Computes the average of the structure across all processes, storing the result on the root process...
subroutine aero_binned_scale_by_array(aero_binned, alpha_array)
Scales an aero_binned_t element-wise by an array of reals.
subroutine aero_binned_input_netcdf(aero_binned, ncid, bin_grid, aero_data)
Read full state.
subroutine aero_binned_zero(aero_binned)
Set all internal data in an aero_binned_t structure to zero.
subroutine pmc_mpi_pack_real_array(buffer, position, val)
Packs the given value into the buffer, advancing position.
integer function pmc_mpi_pack_size_aero_binned(val)
Determine the number of bytes required to pack the structure.
subroutine aero_binned_add_aero_dist(aero_binned, bin_grid, aero_data, aero_dist)
Add an aero_dist_t to an aero_binned_t.
Aerosol material properties and associated data.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
subroutine aero_binned_copy(aero_binned_from, aero_binned_to)
Copy one aero_binned_t structure to another.
subroutine pmc_mpi_reduce_avg_real_array_2d(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on the root process...
subroutine aero_binned_add_scaled(aero_binned, aero_binned_delta, alpha)
Add a scaled aero_binned_t structure to an existing one.
subroutine aero_dist_vol_conc(aero_dist, bin_grid, aero_data, vol_conc)
Return the binned per-species volume concentration for an aero_dist.
Aerosol number and volume distributions stored per bin.