PartMC 2.1.3
Data Types | Functions/Subroutines | Variables
pmc_aero_state Module Reference

The aero_state_t structure and assocated subroutines. More...

Data Types

type  aero_state_t
 The current collection of aerosol particles. More...

Functions/Subroutines

subroutine aero_state_allocate (aero_state)
 Allocates aerosol arrays.
subroutine aero_state_allocate_size (aero_state, n_bin, n_spec, n_source)
 Allocates aerosol arrays with the given sizes.
subroutine aero_state_deallocate (aero_state)
 Deallocates a previously allocated aerosol.
subroutine aero_state_copy (aero_state_from, aero_state_to)
 Copies aerosol to a destination that has already had aero_state_allocate() called on it.
integer aero_state_total_particles (aero_state)
 Returns the total number of particles in an aerosol distribution.
integer aero_state_total_particles_all_procs (aero_state)
 Returns the total number of particles across all processes.
subroutine aero_state_zero (aero_state)
 Resets an aero_state to have zero particles per bin. This must already have had aero_state_allocate() called on it. This function can be called more than once on the same state.
subroutine aero_state_add_particle (aero_state, i_bin, aero_particle)
 Add the given particle.
subroutine aero_state_remove_particle_no_info (aero_state, i_bin, index)
 Remove the given particle without recording it.
subroutine aero_state_remove_particle_with_info (aero_state, i_bin, index, aero_info)
 Remove the given particle and record the removal.
subroutine aero_state_remove_particle (aero_state, i_bin, index, record_removal, aero_info)
 Remove the given particle and possibly record the removal.
subroutine aero_state_remove_rand_particle_from_bin (aero_state, i_bin, aero_particle)
subroutine aero_state_add (aero_state, aero_state_delta)
 aero_state += aero_state_delta, with adding the computational volumes, so the new concentration is the (volume-weighted) average of the two concentration.
subroutine aero_state_add_particles (aero_state, aero_state_delta)
 aero_state += aero_state_delta, with the computational volume of aero_state left unchanged, so the new concentration is the sum of the two concentrations, computed with aero_statecomp_vol.
subroutine aero_state_add_aero_dist_sample (aero_state, bin_grid, aero_data, aero_weight, aero_dist, sample_prop, create_time)
 Generates a Poisson sample of an aero_dist, adding to aero_state. The sampled amount is sample_prop * aero_statecomp_vol.
subroutine aero_state_rand_particle (aero_state, i_bin, i_part)
 Choose a random particle from the aero_state.
subroutine aero_state_sample (aero_state_from, aero_state_to, sample_prob, removal_action)
 Generates a random sample by removing particles from aero_state_from and adding them to aero_state_to, which must be already allocated (and should have its comp_vol set).
subroutine aero_state_to_binned (bin_grid, aero_data, aero_weight, aero_state, aero_binned)
 Create the bin number and mass arrays from aero_statev.
subroutine aero_state_to_binned_dry (bin_grid, aero_data, aero_weight, aero_state, aero_binned)
 Does the same thing as aero_state_to_bin() but based on dry radius.
subroutine aero_state_double (aero_state)
 Doubles number of particles.
subroutine aero_state_halve (aero_state, bin_grid)
 Remove approximately half of the particles in each bin.
subroutine aero_state_resort (bin_grid, aero_state)
 Takes an aero_state_t where the particles might no longer be in the correct bins and resorts it so that every particle is in the correct bin.
subroutine aero_state_mix (aero_state, del_t, mix_timescale, aero_data, bin_grid)
 Mix the aero_states between all processes. Currently uses a simple all-to-all diffusion.
subroutine send_aero_state_mix (dest_proc, aero_state)
 Send the given aero_state to the destination process for mixing.
subroutine recv_aero_state_mix (aero_state)
 Receive exactly one aero_state for mixing and add it on to the given aero_state.
subroutine aero_state_check (bin_grid, aero_data, aero_state)
 Check that all particles are in the correct bins and that the bin numbers and masses are correct. This is for debugging only.
subroutine aero_state_bin_average_comp (aero_state, bin_grid, aero_data, aero_weight, dry_volume)
 Set each aerosol particle to have its original total volume, but species volume ratios given by the total species volume ratio within each bin. This preserves the (weighted) total species volume per bin as well as per-particle total volumes.
subroutine aero_state_bin_average_size (aero_state, bin_grid, aero_data, aero_weight, dry_volume, bin_center, preserve_number)
 Set each aerosol particle to have its original species ratios, but total volume given by the average volume of all particles within each bin.
subroutine aero_state_make_dry (aero_state, bin_grid, aero_data)
 Make all particles dry (water set to zero).
integer pmc_mpi_pack_size_aero_state (val)
 Determines the number of bytes required to pack the given value.
subroutine pmc_mpi_pack_aero_state (buffer, position, val)
 Packs the given value into the buffer, advancing position.
subroutine pmc_mpi_unpack_aero_state (buffer, position, val)
 Unpacks the given value from the buffer, advancing position.
subroutine aero_state_mpi_gather (aero_state, aero_state_total)
 Gathers data from all processes into one aero_state on process 0.
subroutine aero_state_mpi_scatter (aero_state_total, aero_state, aero_data)
 Scatters data from process 0 to all processes by assigning each particle to a random process.
subroutine aero_state_netcdf_dim_aero_particle (aero_state, ncid, dimid_aero_particle)
 Write the aero particle dimension to the given NetCDF file if it is not already present and in any case return the associated dimid.
subroutine aero_state_netcdf_dim_aero_removed (aero_state, ncid, dimid_aero_removed)
 Write the aero removed dimension to the given NetCDF file if it is not already present and in any case return the associated dimid.
subroutine aero_state_output_netcdf (aero_state, ncid, bin_grid, aero_data, aero_weight, record_removals, record_optical)
 Write full state.
subroutine aero_state_input_netcdf (aero_state, ncid, bin_grid, aero_data, aero_weight)
 Read full state.

Variables

integer, parameter AERO_STATE_TAG_MIX = 4987
 MPI tag for mixing particles between processes.
integer, parameter AERO_STATE_TAG_GATHER = 4988
 MPI tag for gathering between processes.
integer, parameter AERO_STATE_TAG_SCATTER = 4989
 MPI tag for scattering between processes.

Detailed Description

The aero_state_t structure and assocated subroutines.


Function/Subroutine Documentation

subroutine pmc_aero_state::aero_state_add ( type(aero_state_t),intent(inout)  aero_state,
type(aero_state_t),intent(in)  aero_state_delta 
)

aero_state += aero_state_delta, with adding the computational volumes, so the new concentration is the (volume-weighted) average of the two concentration.

Parameters:
aero_stateAerosol state.
aero_state_deltaIncrement.

Definition at line 327 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_add_aero_dist_sample ( type(aero_state_t),intent(inout)  aero_state,
type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_weight_t),intent(in)  aero_weight,
type(aero_dist_t),intent(in)  aero_dist,
real(kind=dp),intent(in)  sample_prop,
real(kind=dp),intent(in)  create_time 
)

Generates a Poisson sample of an aero_dist, adding to aero_state. The sampled amount is sample_prop * aero_statecomp_vol.

Parameters:
aero_stateAero state to add to.
bin_gridBin grid.
aero_dataAero data values.
aero_weightAerosol weight.
aero_distDistribution to sample.
sample_propVolume fraction to sample (1).
create_timeCreation time for new particles (s).

Definition at line 371 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_add_particle ( type(aero_state_t),intent(inout)  aero_state,
integer,intent(in)  i_bin,
type(aero_particle_t),intent(in)  aero_particle 
)

Add the given particle.

Parameters:
aero_stateAerosol state.
i_binBin number of particle to add.
aero_particleParticle to add.

Definition at line 221 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_add_particles ( type(aero_state_t),intent(inout)  aero_state,
type(aero_state_t),intent(in)  aero_state_delta 
)

aero_state += aero_state_delta, with the computational volume of aero_state left unchanged, so the new concentration is the sum of the two concentrations, computed with aero_statecomp_vol.

Parameters:
aero_stateAerosol state.
aero_state_deltaIncrement.

Definition at line 344 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_allocate ( type(aero_state_t),intent(out)  aero_state)

Allocates aerosol arrays.

Parameters:
aero_stateAerosol to initialize.

Definition at line 84 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_allocate_size ( type(aero_state_t),intent(out)  aero_state,
integer,intent(in)  n_bin,
integer,intent(in)  n_spec,
integer,intent(in)  n_source 
)

Allocates aerosol arrays with the given sizes.

Parameters:
aero_stateAerosol to initialize.
n_binNumber of bins.
n_specNumber of species.
n_sourceNumber of sources.

Definition at line 97 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_bin_average_comp ( type(aero_state_t),intent(inout)  aero_state,
type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_weight_t),intent(in)  aero_weight,
logical,intent(in)  dry_volume 
)

Set each aerosol particle to have its original total volume, but species volume ratios given by the total species volume ratio within each bin. This preserves the (weighted) total species volume per bin as well as per-particle total volumes.

Parameters:
aero_stateAerosol state to average.
bin_gridBin grid to average within.
aero_dataAerosol data.
aero_weightAerosol weight.
dry_volumeWhether to use dry volume (rather than wet).

Definition at line 956 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_bin_average_size ( type(aero_state_t),intent(inout)  aero_state,
type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_weight_t),intent(in)  aero_weight,
logical,intent(in)  dry_volume,
logical,intent(in)  bin_center,
logical,intent(in)  preserve_number 
)

Set each aerosol particle to have its original species ratios, but total volume given by the average volume of all particles within each bin.

This does not preserve the total species volume per bin. If the bin_center parameter is .true. then the particles in each bin are set to have the bin center volume, rather than the average volume of the particles in that bin.

If the weighting function is not constant (AERO_WEIGHT_TYPE_NONE) then the averaging can be performed in either a number-preserving way or in a volume-preserving way. The volume-preserving way does not preserve species volume ratios in gernal, but will do so if the particle population has already been composition-averaged.

Parameters:
aero_stateAerosol state to average.
bin_gridBin grid to average within.
aero_dataAerosol data.
aero_weightAerosol weight.
dry_volumeWhether to use dry volume (rather than wet).
bin_centerWhether to assign the bin center volume (rather than the average volume).
preserve_numberWhether to use the number-preserving scheme (otherwise will use the volume-preserving scheme). This parameter has no effect if bin_center is .true.

Definition at line 1020 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_check ( type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_state_t),intent(inout)  aero_state 
)

Check that all particles are in the correct bins and that the bin numbers and masses are correct. This is for debugging only.

Parameters:
bin_gridBin_grid.
aero_dataAerosol data.
aero_stateAerosol state.

Definition at line 880 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_copy ( type(aero_state_t),intent(in)  aero_state_from,
type(aero_state_t),intent(inout)  aero_state_to 
)

Copies aerosol to a destination that has already had aero_state_allocate() called on it.

Parameters:
aero_state_fromReference aerosol.
aero_state_toAlready allocated.

Definition at line 144 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_deallocate ( type(aero_state_t),intent(inout)  aero_state)

Deallocates a previously allocated aerosol.

Parameters:
aero_stateAerosol to deallocate.

Definition at line 124 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_double ( type(aero_state_t),intent(inout)  aero_state)

Doubles number of particles.

Parameters:
aero_stateAerosol state.

Definition at line 597 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_halve ( type(aero_state_t),intent(inout)  aero_state,
type(bin_grid_t),intent(in)  bin_grid 
)

Remove approximately half of the particles in each bin.

Parameters:
aero_stateAerosol state.
bin_gridBin grid.

Definition at line 616 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_input_netcdf ( type(aero_state_t),intent(inout)  aero_state,
integer,intent(in)  ncid,
type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_weight_t),intent(in)  aero_weight 
)

Read full state.

Parameters:
aero_stateaero_state to read.
ncidNetCDF file ID, in data mode.
bin_gridbin_grid structure.
aero_dataaero_data structure.
aero_weightaero_weight structure.

Definition at line 1884 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_make_dry ( type(aero_state_t),intent(inout)  aero_state,
type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data 
)

Make all particles dry (water set to zero).

Parameters:
aero_stateAerosol state to make dry.
bin_gridBin grid.
aero_dataAerosol data.

Definition at line 1188 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_mix ( type(aero_state_t),intent(inout)  aero_state,
real(kind=dp),intent(in)  del_t,
real(kind=dp),intent(in)  mix_timescale,
type(aero_data_t),intent(in)  aero_data,
type(bin_grid_t),intent(in)  bin_grid 
)

Mix the aero_states between all processes. Currently uses a simple all-to-all diffusion.

Parameters:
aero_stateAerosol state.
del_tTimestep (s).
mix_timescaleMixing timescale (s).
aero_dataAero data values.
bin_gridBin grid.

Definition at line 702 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_mpi_gather ( type(aero_state_t),intent(in)  aero_state,
type(aero_state_t),intent(inout)  aero_state_total 
)

Gathers data from all processes into one aero_state on process 0.

Parameters:
aero_stateLocal aero_state.
aero_state_totalCentralized aero_state (only on process 0).

Definition at line 1298 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_mpi_scatter ( type(aero_state_t),intent(in)  aero_state_total,
type(aero_state_t),intent(inout)  aero_state,
type(aero_data_t),intent(in)  aero_data 
)

Scatters data from process 0 to all processes by assigning each particle to a random process.

Parameters:
aero_state_totalCentralized aero_state (only on process 0.
aero_stateLocal aero_state.
aero_dataAero_data.

Definition at line 1370 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_netcdf_dim_aero_particle ( type(aero_state_t),intent(in)  aero_state,
integer,intent(in)  ncid,
integer,intent(out)  dimid_aero_particle 
)

Write the aero particle dimension to the given NetCDF file if it is not already present and in any case return the associated dimid.

Parameters:
aero_stateaero_state structure.
ncidNetCDF file ID, in data mode.
dimid_aero_particleDimid of the aero particle dimension.

Definition at line 1466 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_netcdf_dim_aero_removed ( type(aero_state_t),intent(in)  aero_state,
integer,intent(in)  ncid,
integer,intent(out)  dimid_aero_removed 
)

Write the aero removed dimension to the given NetCDF file if it is not already present and in any case return the associated dimid.

Parameters:
aero_stateaero_state structure.
ncidNetCDF file ID, in data mode.
dimid_aero_removedDimid of the aero removed dimension.

Definition at line 1507 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_output_netcdf ( type(aero_state_t),intent(in)  aero_state,
integer,intent(in)  ncid,
type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_weight_t),intent(in)  aero_weight,
logical,intent(in)  record_removals,
logical,intent(in)  record_optical 
)

Write full state.

Parameters:
aero_stateaero_state to write.
ncidNetCDF file ID, in data mode.
bin_gridbin_grid structure.
aero_dataaero_data structure.
aero_weightaero_weight structure.
record_removalsWhether to output particle removal info.
record_opticalWhether to output aerosol optical properties.

Definition at line 1547 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_rand_particle ( type(aero_state_t),intent(in)  aero_state,
integer,intent(out)  i_bin,
integer,intent(out)  i_part 
)

Choose a random particle from the aero_state.

Parameters:
aero_stateOriginal state.
i_binBin number of particle.
i_partParticle number within bin.

Definition at line 421 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_remove_particle ( type(aero_state_t),intent(inout)  aero_state,
integer,intent(in)  i_bin,
integer,intent(in)  index,
logical,intent(in)  record_removal,
type(aero_info_t),intent(in)  aero_info 
)

Remove the given particle and possibly record the removal.

Parameters:
aero_stateAerosol state.
i_binBin number of particle to remove.
indexIndex in bin of particle to remove.
record_removalWhether to record the removal in the aero_info_array.
aero_infoRemoval info.

Definition at line 277 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_remove_particle_no_info ( type(aero_state_t),intent(inout)  aero_state,
integer,intent(in)  i_bin,
integer,intent(in)  index 
)

Remove the given particle without recording it.

Parameters:
aero_stateAerosol state.
i_binBin number of particle to remove.
indexIndex in bin of particle to remove.

Definition at line 239 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_remove_particle_with_info ( type(aero_state_t),intent(inout)  aero_state,
integer,intent(in)  i_bin,
integer,intent(in)  index,
type(aero_info_t),intent(in)  aero_info 
)

Remove the given particle and record the removal.

Parameters:
aero_stateAerosol state.
i_binBin number of particle to remove.
indexIndex in bin of particle to remove.
aero_infoRemoval info.

Definition at line 256 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_remove_rand_particle_from_bin ( type(aero_state_t),intent(inout)  aero_state,
integer,intent(in)  i_bin,
type(aero_particle_t),intent(inout)  aero_particle 
)
Parameters:
aero_stateAerosol state.
i_binBin number to remove particle from.
aero_particleRemoved particle.

Definition at line 302 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_resort ( type(bin_grid_t),intent(in)  bin_grid,
type(aero_state_t),intent(inout)  aero_state 
)

Takes an aero_state_t where the particles might no longer be in the correct bins and resorts it so that every particle is in the correct bin.

Parameters:
bin_gridBin_grid.
aero_stateAerosol state.

Definition at line 651 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_sample ( type(aero_state_t),intent(inout)  aero_state_from,
type(aero_state_t),intent(inout)  aero_state_to,
real(kind=dp),intent(in)  sample_prob,
integer,intent(in)  removal_action 
)

Generates a random sample by removing particles from aero_state_from and adding them to aero_state_to, which must be already allocated (and should have its comp_vol set).

Parameters:
aero_state_fromOriginal state.
aero_state_toDestination state.
sample_probProbability of sampling each particle.
removal_actionAction for removal (see pmc_aero_info module for action parameters). Set to AERO_INFO_NONE to not log removal.

Definition at line 445 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_to_binned ( type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_weight_t),intent(in)  aero_weight,
type(aero_state_t),intent(in)  aero_state,
type(aero_binned_t),intent(inout)  aero_binned 
)

Create the bin number and mass arrays from aero_statev.

Parameters:
bin_gridBin grid.
aero_dataAerosol data.
aero_weightAerosol weight.
aero_stateAerosol state.
aero_binnedBinned distributions.

Definition at line 519 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_to_binned_dry ( type(bin_grid_t),intent(in)  bin_grid,
type(aero_data_t),intent(in)  aero_data,
type(aero_weight_t),intent(in)  aero_weight,
type(aero_state_t),intent(in)  aero_state,
type(aero_binned_t),intent(inout)  aero_binned 
)

Does the same thing as aero_state_to_bin() but based on dry radius.

Parameters:
bin_gridBin grid.
aero_dataAerosol data.
aero_weightAerosol weight.
aero_stateAerosol state.
aero_binnedBinned distributions.

Definition at line 557 of file aero_state.F90.

integer pmc_aero_state::aero_state_total_particles ( type(aero_state_t),intent(in)  aero_state)

Returns the total number of particles in an aerosol distribution.

Parameters:
aero_stateAerosol state.

Definition at line 174 of file aero_state.F90.

integer pmc_aero_state::aero_state_total_particles_all_procs ( type(aero_state_t),intent(in)  aero_state)

Returns the total number of particles across all processes.

Parameters:
aero_stateAerosol state.

Definition at line 186 of file aero_state.F90.

subroutine pmc_aero_state::aero_state_zero ( type(aero_state_t),intent(inout)  aero_state)

Resets an aero_state to have zero particles per bin. This must already have had aero_state_allocate() called on it. This function can be called more than once on the same state.

Parameters:
aero_stateState to zero.

Definition at line 202 of file aero_state.F90.

subroutine pmc_aero_state::pmc_mpi_pack_aero_state ( character,dimension(:),intent(inout)  buffer,
integer,intent(inout)  position,
type(aero_state_t),intent(in)  val 
)

Packs the given value into the buffer, advancing position.

Parameters:
bufferMemory buffer.
positionCurrent buffer position.
valValue to pack.

Definition at line 1236 of file aero_state.F90.

integer pmc_aero_state::pmc_mpi_pack_size_aero_state ( type(aero_state_t),intent(in)  val)

Determines the number of bytes required to pack the given value.

Parameters:
valValue to pack.

Definition at line 1214 of file aero_state.F90.

subroutine pmc_aero_state::pmc_mpi_unpack_aero_state ( character,dimension(:),intent(inout)  buffer,
integer,intent(inout)  position,
type(aero_state_t),intent(inout)  val 
)

Unpacks the given value from the buffer, advancing position.

Parameters:
bufferMemory buffer.
positionCurrent buffer position.
valValue to pack.

Definition at line 1265 of file aero_state.F90.

subroutine pmc_aero_state::recv_aero_state_mix ( type(aero_state_t),intent(inout)  aero_state)

Receive exactly one aero_state for mixing and add it on to the given aero_state.

Parameters:
aero_stateBase aero_state to add new particles to.

Definition at line 833 of file aero_state.F90.

subroutine pmc_aero_state::send_aero_state_mix ( integer,intent(in)  dest_proc,
type(aero_state_t),intent(in)  aero_state 
)

Send the given aero_state to the destination process for mixing.

Parameters:
dest_procDestination process number.
aero_stateAero_state to send.

Definition at line 802 of file aero_state.F90.


Variable Documentation

integer,parameter pmc_aero_state::AERO_STATE_TAG_GATHER = 4988

MPI tag for gathering between processes.

Definition at line 31 of file aero_state.F90.

integer,parameter pmc_aero_state::AERO_STATE_TAG_MIX = 4987

MPI tag for mixing particles between processes.

Definition at line 29 of file aero_state.F90.

integer,parameter pmc_aero_state::AERO_STATE_TAG_SCATTER = 4989

MPI tag for scattering between processes.

Definition at line 33 of file aero_state.F90.