PartMC  2.3.0
aero_info.F90
Go to the documentation of this file.
1 ! Copyright (C) 2009-2011 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  !> Allocates and initializes.
63  subroutine aero_info_allocate(aero_info)
64 
65  !> Result.
66  type(aero_info_t), intent(out) :: aero_info
67 
68  call aero_info_zero(aero_info)
69 
70  end subroutine aero_info_allocate
71 
72 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
73 
74  !> Deallocates.
75  subroutine aero_info_deallocate(aero_info)
76 
77  !> Structure to deallocate.
78  type(aero_info_t), intent(inout) :: aero_info
79 
80  end subroutine aero_info_deallocate
81 
82 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
83 
84  !> Copies aero_info_from to aero_info_to, both
85  !> of which must already be allocated.
86  subroutine aero_info_copy(aero_info_from, &
87  aero_info_to)
88 
89  !> Origin structure.
90  type(aero_info_t), intent(in) :: aero_info_from
91  !> Destination structure.
92  type(aero_info_t), intent(inout) :: aero_info_to
93 
94  aero_info_to%id = aero_info_from%id
95  aero_info_to%action = aero_info_from%action
96  aero_info_to%other_id = aero_info_from%other_id
97 
98  end subroutine aero_info_copy
99 
100 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
101 
102  !> Resets an aero_info to contain zero particles.
103  subroutine aero_info_zero(aero_info)
104 
105  !> Structure to reset.
106  type(aero_info_t), intent(inout) :: aero_info
107 
108  aero_info%id = 0
109  aero_info%action = aero_info_none
110  aero_info%other_id = 0
111 
112  end subroutine aero_info_zero
113 
114 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
115 
116  !> Determines the number of bytes required to pack the given value.
117  integer function pmc_mpi_pack_size_aero_info(val)
118 
119  !> Value to pack.
120  type(aero_info_t), intent(in) :: val
121 
122  integer :: total_size
123 
124  total_size = 0
125  total_size = total_size + pmc_mpi_pack_size_integer(val%id)
126  total_size = total_size + pmc_mpi_pack_size_integer(val%action)
127  total_size = total_size + pmc_mpi_pack_size_integer(val%other_id)
128  pmc_mpi_pack_size_aero_info = total_size
129 
130  end function pmc_mpi_pack_size_aero_info
131 
132 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
133 
134  !> Packs the given value into the buffer, advancing position.
135  subroutine pmc_mpi_pack_aero_info(buffer, position, val)
136 
137  !> Memory buffer.
138  character, intent(inout) :: buffer(:)
139  !> Current buffer position.
140  integer, intent(inout) :: position
141  !> Value to pack.
142  type(aero_info_t), intent(in) :: val
143 
144 #ifdef PMC_USE_MPI
145  integer :: prev_position
146 
147  prev_position = position
148  call pmc_mpi_pack_integer(buffer, position, val%id)
149  call pmc_mpi_pack_integer(buffer, position, val%action)
150  call pmc_mpi_pack_integer(buffer, position, val%other_id)
151  call assert(842929827, &
152  position - prev_position <= pmc_mpi_pack_size_aero_info(val))
153 #endif
154 
155  end subroutine pmc_mpi_pack_aero_info
156 
157 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
158 
159  !> Unpacks the given value from the buffer, advancing position.
160  subroutine pmc_mpi_unpack_aero_info(buffer, position, val)
161 
162  !> Memory buffer.
163  character, intent(inout) :: buffer(:)
164  !> Current buffer position.
165  integer, intent(inout) :: position
166  !> Value to pack.
167  type(aero_info_t), intent(inout) :: val
168 
169 #ifdef PMC_USE_MPI
170  integer :: prev_position
171 
172  prev_position = position
173  call pmc_mpi_unpack_integer(buffer, position, val%id)
174  call pmc_mpi_unpack_integer(buffer, position, val%action)
175  call pmc_mpi_unpack_integer(buffer, position, val%other_id)
176  call assert(841267392, &
177  position - prev_position <= pmc_mpi_pack_size_aero_info(val))
178 #endif
179 
180  end subroutine pmc_mpi_unpack_aero_info
181 
182 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
183 
184 end module pmc_aero_info
subroutine aero_info_copy(aero_info_from, aero_info_to)
Copies aero_info_from to aero_info_to, both of which must already be allocated.
Definition: aero_info.F90:86
integer function pmc_mpi_pack_size_integer(val)
Determines the number of bytes required to pack the given value.
Definition: mpi.F90:347
subroutine aero_info_deallocate(aero_info)
Deallocates.
Definition: aero_info.F90:75
integer function pmc_mpi_pack_size_aero_info(val)
Determines the number of bytes required to pack the given value.
Definition: aero_info.F90:117
subroutine aero_info_allocate(aero_info)
Allocates and initializes.
Definition: aero_info.F90:63
subroutine pmc_mpi_pack_integer(buffer, position, val)
Packs the given value into the buffer, advancing position.
Definition: mpi.F90:534
Common utility subroutines.
Definition: util.F90:9
subroutine pmc_mpi_unpack_integer(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
Definition: mpi.F90:771
The aero_info_t structure and associated subroutines.
Definition: aero_info.F90:9
Wrapper functions for MPI.
Definition: mpi.F90:13
subroutine aero_info_zero(aero_info)
Resets an aero_info to contain zero particles.
Definition: aero_info.F90:103
subroutine pmc_mpi_unpack_aero_info(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
Definition: aero_info.F90:160
subroutine pmc_mpi_pack_aero_info(buffer, position, val)
Packs the given value into the buffer, advancing position.
Definition: aero_info.F90:135
Reading formatted text input.
Definition: spec_file.F90:43
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
Definition: util.F90:102
Information about removed particles describing the sink.
Definition: aero_info.F90:48