PartMC  2.6.1
aero_info.F90
Go to the documentation of this file.
1 ! Copyright (C) 2009-2012 Nicole Riemer and Matthew West
2 ! Licensed under the GNU General Public License version 2 or (at your
3 ! option) any later version. See the file COPYING for details.
4 
5 !> \file
6 !> The pmc_aero_info module.
7 
8 !> The aero_info_t structure and associated subroutines.
10 
11  use pmc_util
12  use pmc_spec_file
13  use pmc_mpi
14 #ifdef PMC_USE_MPI
15  use mpi
16 #endif
17 
18  !> No information.
19  integer, parameter :: aero_info_none = 0
20  !> Particle was removed due to dilution with outside air.
21  integer, parameter :: aero_info_dilution = 1
22  !> Particle was removed due to coagulation.
23  integer, parameter :: aero_info_coag = 2
24  !> Particle was removed due to halving of the aerosol population.
25  integer, parameter :: aero_info_halved = 3
26  !> Particle was removed due to adjustments in the particle's
27  !> weighting function.
28  integer, parameter :: aero_info_weight = 4
29 
30  !> Information about removed particles describing the sink.
31  !!
32  !! For each particle that is removed from the particle population
33  !! the aero_info_t structure gives the ID of the removed particle
34  !! and the action (dilution, coagulation, emission, etc) that caused
35  !! the removal. The action must be one of the AERO_INFO_* parameters
36  !! in the pmc_aero_info module. If the action is AERO_INFO_COAG then
37  !! the other_id field will store the ID of the particle that was
38  !! produced by the coagulation.
39  !!
40  !! Coagulation always occurs between two particles and the resulting
41  !! particle takes the ID of one of the two original particles, or a
42  !! new ID. If either of the coagulating particles does not have its
43  !! ID inherited by the new particle then it will be recorded in an
44  !! \c aero_info_t structure. If the ID of the new coagulated
45  !! particle is the same as one of the coagulating particles then it
46  !! is not considered to have been lost and is not recorded in an
47  !! aero_info_t structure.
49  !> Particle ID number.
50  integer :: id
51  !> Action on this particle (from AERO_INFO_* parameters).
52  integer :: action
53  !> ID number of the new coagulated particle, or 0 if the new
54  !> particle was not created.
55  integer :: other_id
56  end type aero_info_t
57 
58 contains
59 
60 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
61 
62  !> Determines the number of bytes required to pack the given value.
63  integer function pmc_mpi_pack_size_aero_info(val)
64 
65  !> Value to pack.
66  type(aero_info_t), intent(in) :: val
67 
68  integer :: total_size
69 
70  total_size = 0
71  total_size = total_size + pmc_mpi_pack_size_integer(val%id)
72  total_size = total_size + pmc_mpi_pack_size_integer(val%action)
73  total_size = total_size + pmc_mpi_pack_size_integer(val%other_id)
74  pmc_mpi_pack_size_aero_info = total_size
75 
76  end function pmc_mpi_pack_size_aero_info
77 
78 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
79 
80  !> Packs the given value into the buffer, advancing position.
81  subroutine pmc_mpi_pack_aero_info(buffer, position, val)
82 
83  !> Memory buffer.
84  character, intent(inout) :: buffer(:)
85  !> Current buffer position.
86  integer, intent(inout) :: position
87  !> Value to pack.
88  type(aero_info_t), intent(in) :: val
89 
90 #ifdef PMC_USE_MPI
91  integer :: prev_position
92 
93  prev_position = position
94  call pmc_mpi_pack_integer(buffer, position, val%id)
95  call pmc_mpi_pack_integer(buffer, position, val%action)
96  call pmc_mpi_pack_integer(buffer, position, val%other_id)
97  call assert(842929827, &
98  position - prev_position <= pmc_mpi_pack_size_aero_info(val))
99 #endif
100 
101  end subroutine pmc_mpi_pack_aero_info
102 
103 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
104 
105  !> Unpacks the given value from the buffer, advancing position.
106  subroutine pmc_mpi_unpack_aero_info(buffer, position, val)
107 
108  !> Memory buffer.
109  character, intent(inout) :: buffer(:)
110  !> Current buffer position.
111  integer, intent(inout) :: position
112  !> Value to pack.
113  type(aero_info_t), intent(inout) :: val
114 
115 #ifdef PMC_USE_MPI
116  integer :: prev_position
117 
118  prev_position = position
119  call pmc_mpi_unpack_integer(buffer, position, val%id)
120  call pmc_mpi_unpack_integer(buffer, position, val%action)
121  call pmc_mpi_unpack_integer(buffer, position, val%other_id)
122  call assert(841267392, &
123  position - prev_position <= pmc_mpi_pack_size_aero_info(val))
124 #endif
125 
126  end subroutine pmc_mpi_unpack_aero_info
127 
128 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
129 
130 end module pmc_aero_info
pmc_mpi
Wrapper functions for MPI.
Definition: mpi.F90:13
pmc_aero_info::aero_info_coag
integer, parameter aero_info_coag
Particle was removed due to coagulation.
Definition: aero_info.F90:23
pmc_aero_info::aero_info_dilution
integer, parameter aero_info_dilution
Particle was removed due to dilution with outside air.
Definition: aero_info.F90:21
pmc_aero_info::pmc_mpi_pack_size_aero_info
integer function pmc_mpi_pack_size_aero_info(val)
Determines the number of bytes required to pack the given value.
Definition: aero_info.F90:64
pmc_aero_info::pmc_mpi_unpack_aero_info
subroutine pmc_mpi_unpack_aero_info(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
Definition: aero_info.F90:107
pmc_spec_file
Reading formatted text input.
Definition: spec_file.F90:43
pmc_util::assert
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
Definition: util.F90:103
pmc_aero_info::pmc_mpi_pack_aero_info
subroutine pmc_mpi_pack_aero_info(buffer, position, val)
Packs the given value into the buffer, advancing position.
Definition: aero_info.F90:82
pmc_aero_info::aero_info_none
integer, parameter aero_info_none
No information.
Definition: aero_info.F90:19
pmc_aero_info::aero_info_halved
integer, parameter aero_info_halved
Particle was removed due to halving of the aerosol population.
Definition: aero_info.F90:25
pmc_mpi::pmc_mpi_unpack_integer
subroutine pmc_mpi_unpack_integer(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
Definition: mpi.F90:818
pmc_aero_info::aero_info_t
Information about removed particles describing the sink.
Definition: aero_info.F90:48
pmc_util
Common utility subroutines.
Definition: util.F90:9
pmc_aero_info
The aero_info_t structure and associated subroutines.
Definition: aero_info.F90:9
pmc_mpi::pmc_mpi_pack_size_integer
integer function pmc_mpi_pack_size_integer(val)
Determines the number of bytes required to pack the given value.
Definition: mpi.F90:345
pmc_mpi::pmc_mpi_pack_integer
subroutine pmc_mpi_pack_integer(buffer, position, val)
Packs the given value into the buffer, advancing position.
Definition: mpi.F90:561
pmc_aero_info::aero_info_weight
integer, parameter aero_info_weight
Particle was removed due to adjustments in the particle's weighting function.
Definition: aero_info.F90:28