forked from open-atmos/PyPartMC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_part.F90
262 lines (213 loc) · 9.4 KB
/
run_part.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
!###################################################################################################
! This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
! Copyright (C) 2022 University of Illinois Urbana-Champaign #
! Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
!###################################################################################################
module PyPartMC_run_part
use iso_c_binding
use pmc_run_part
implicit none
contains
subroutine f_run_part( &
scenario_ptr_c, &
env_state_ptr_c, &
aero_data_ptr_c, &
aero_state_ptr_c, &
gas_data_ptr_c, &
gas_state_ptr_c, &
run_part_opt_ptr_c, &
camp_core_ptr_c, &
photolysis_ptr_c &
) bind(C)
type(c_ptr), intent(in) :: scenario_ptr_c
type(scenario_t), pointer :: scenario_ptr_f => null()
type(c_ptr), intent(in) :: env_state_ptr_c
type(env_state_t), pointer :: env_state_ptr_f => null()
type(c_ptr), intent(in) :: aero_data_ptr_c
type(aero_data_t), pointer :: aero_data_ptr_f => null()
type(c_ptr), intent(in) :: aero_state_ptr_c
type(aero_state_t), pointer :: aero_state_ptr_f => null()
type(c_ptr), intent(in) :: gas_data_ptr_c
type(gas_data_t), pointer :: gas_data_ptr_f => null()
type(c_ptr), intent(in) :: gas_state_ptr_c
type(gas_state_t), pointer :: gas_state_ptr_f => null()
type(c_ptr), intent(in) :: run_part_opt_ptr_c
type(run_part_opt_t), pointer :: run_part_opt_ptr_f => null()
type(c_ptr), intent(in) :: camp_core_ptr_c
type(camp_core_t), pointer :: camp_core_ptr_f => null()
type(c_ptr), intent(in) :: photolysis_ptr_c
type(photolysis_t), pointer :: photolysis_ptr_f => null()
call c_f_pointer(scenario_ptr_c, scenario_ptr_f)
call c_f_pointer(env_state_ptr_c, env_state_ptr_f)
call c_f_pointer(aero_data_ptr_c, aero_data_ptr_f)
call c_f_pointer(aero_state_ptr_c, aero_state_ptr_f)
call c_f_pointer(gas_data_ptr_c, gas_data_ptr_f)
call c_f_pointer(gas_state_ptr_c, gas_state_ptr_f)
call c_f_pointer(run_part_opt_ptr_c, run_part_opt_ptr_f)
call c_f_pointer(camp_core_ptr_c, camp_core_ptr_f)
call c_f_pointer(photolysis_ptr_c, photolysis_ptr_f)
call run_part( &
scenario_ptr_f, &
env_state_ptr_f, &
aero_data_ptr_f, &
aero_state_ptr_f, &
gas_data_ptr_f, &
gas_state_ptr_f, &
run_part_opt_ptr_f, &
camp_core_ptr_f, &
photolysis_ptr_f &
)
end subroutine
subroutine f_run_part_timestep( &
scenario_ptr_c, &
env_state_ptr_c, &
aero_data_ptr_c, &
aero_state_ptr_c, &
gas_data_ptr_c, &
gas_state_ptr_c, &
run_part_opt_ptr_c, &
camp_core_ptr_c, &
photolysis_ptr_c, &
i_time, &
t_start, &
last_output_time, &
last_progress_time, &
i_output &
) bind(C)
type(c_ptr), intent(in) :: scenario_ptr_c
type(scenario_t), pointer :: scenario_ptr_f => null()
type(c_ptr), intent(inout) :: env_state_ptr_c
type(env_state_t), pointer :: env_state_ptr_f => null()
type(c_ptr), intent(inout) :: aero_data_ptr_c
type(aero_data_t), pointer :: aero_data_ptr_f => null()
type(c_ptr), intent(inout) :: aero_state_ptr_c
type(aero_state_t), pointer :: aero_state_ptr_f => null()
type(c_ptr), intent(inout) :: gas_data_ptr_c
type(gas_data_t), pointer :: gas_data_ptr_f => null()
type(c_ptr), intent(inout) :: gas_state_ptr_c
type(gas_state_t), pointer :: gas_state_ptr_f => null()
type(c_ptr), intent(in) :: run_part_opt_ptr_c
type(run_part_opt_t), pointer :: run_part_opt_ptr_f => null()
type(c_ptr), intent(in) :: camp_core_ptr_c
type(camp_core_t), pointer :: camp_core_ptr_f => null()
type(c_ptr), intent(in) :: photolysis_ptr_c
type(photolysis_t), pointer :: photolysis_ptr_f => null()
integer(c_int), intent(in) :: i_time
real(c_double), intent(in) :: t_start
real(c_double), intent(inout) :: last_output_time
real(c_double), intent(inout) :: last_progress_time
integer(c_int), intent(inout) :: i_output
integer(c_int) :: progress_n_samp, progress_n_coag, &
progress_n_emit, progress_n_dil_in, progress_n_dil_out, &
progress_n_nuc
call c_f_pointer(scenario_ptr_c, scenario_ptr_f)
call c_f_pointer(env_state_ptr_c, env_state_ptr_f)
call c_f_pointer(aero_data_ptr_c, aero_data_ptr_f)
call c_f_pointer(aero_state_ptr_c, aero_state_ptr_f)
call c_f_pointer(gas_data_ptr_c, gas_data_ptr_f)
call c_f_pointer(gas_state_ptr_c, gas_state_ptr_f)
call c_f_pointer(run_part_opt_ptr_c, run_part_opt_ptr_f)
call c_f_pointer(camp_core_ptr_c, camp_core_ptr_f)
call c_f_pointer(photolysis_ptr_c, photolysis_ptr_f)
progress_n_samp = 0
progress_n_coag = 0
progress_n_emit = 0
progress_n_dil_in = 0
progress_n_dil_out = 0
progress_n_nuc = 0
if (env_state_ptr_f%elapsed_time < run_part_opt_ptr_f%del_t) then
call mosaic_init(env_state_ptr_f, aero_data_ptr_f, run_part_opt_ptr_f%del_t, &
run_part_opt_ptr_f%do_optical)
if (run_part_opt_ptr_f%t_output > 0) then
call output_state(run_part_opt_ptr_f%output_prefix, &
run_part_opt_ptr_f%output_type, aero_data_ptr_f, aero_state_ptr_f, gas_data_ptr_f, &
gas_state_ptr_f, env_state_ptr_f, 1, .0d0, run_part_opt_ptr_f%del_t, &
run_part_opt_ptr_f%i_repeat, run_part_opt_ptr_f%record_removals, &
run_part_opt_ptr_f%do_optical, run_part_opt_ptr_f%uuid)
end if
end if
call run_part_timestep(scenario_ptr_f, env_state_ptr_f, aero_data_ptr_f, aero_state_ptr_f, &
gas_data_ptr_f, gas_state_ptr_f, run_part_opt_ptr_f, camp_core_ptr_f, photolysis_ptr_f, &
i_time, t_start, last_output_time, &
last_progress_time, i_output, progress_n_samp, progress_n_coag, &
progress_n_emit, progress_n_dil_in, progress_n_dil_out, &
progress_n_nuc)
end subroutine
subroutine f_run_part_timeblock( &
scenario_ptr_c, &
env_state_ptr_c, &
aero_data_ptr_c, &
aero_state_ptr_c, &
gas_data_ptr_c, &
gas_state_ptr_c, &
run_part_opt_ptr_c, &
camp_core_ptr_c, &
photolysis_ptr_c, &
i_time, &
i_next, &
t_start, &
last_output_time, &
last_progress_time, &
i_output &
) bind(C)
type(c_ptr), intent(in) :: scenario_ptr_c
type(scenario_t), pointer :: scenario_ptr_f => null()
type(c_ptr), intent(in) :: env_state_ptr_c
type(env_state_t), pointer :: env_state_ptr_f => null()
type(c_ptr), intent(in) :: aero_data_ptr_c
type(aero_data_t), pointer :: aero_data_ptr_f => null()
type(c_ptr), intent(in) :: aero_state_ptr_c
type(aero_state_t), pointer :: aero_state_ptr_f => null()
type(c_ptr), intent(in) :: gas_data_ptr_c
type(gas_data_t), pointer :: gas_data_ptr_f => null()
type(c_ptr), intent(in) :: gas_state_ptr_c
type(gas_state_t), pointer :: gas_state_ptr_f => null()
type(c_ptr), intent(in) :: run_part_opt_ptr_c
type(run_part_opt_t), pointer :: run_part_opt_ptr_f => null()
type(c_ptr), intent(in) :: camp_core_ptr_c
type(camp_core_t), pointer :: camp_core_ptr_f => null()
type(c_ptr), intent(in) :: photolysis_ptr_c
type(photolysis_t), pointer :: photolysis_ptr_f => null()
integer(c_int), intent(in) :: i_time
integer(c_int), intent(in) :: i_next
real(c_double), intent(in) :: t_start
real(c_double), intent(inout) :: last_output_time
real(c_double), intent(inout) :: last_progress_time
integer(c_int), intent(inout) :: i_output
integer(c_int) :: progress_n_samp, progress_n_coag, &
progress_n_emit, progress_n_dil_in, progress_n_dil_out, &
progress_n_nuc
call c_f_pointer(scenario_ptr_c, scenario_ptr_f)
call c_f_pointer(env_state_ptr_c, env_state_ptr_f)
call c_f_pointer(aero_data_ptr_c, aero_data_ptr_f)
call c_f_pointer(aero_state_ptr_c, aero_state_ptr_f)
call c_f_pointer(gas_data_ptr_c, gas_data_ptr_f)
call c_f_pointer(gas_state_ptr_c, gas_state_ptr_f)
call c_f_pointer(run_part_opt_ptr_c, run_part_opt_ptr_f)
call c_f_pointer(camp_core_ptr_c, camp_core_ptr_f)
call c_f_pointer(photolysis_ptr_c, photolysis_ptr_f)
progress_n_samp = 0
progress_n_coag = 0
progress_n_emit = 0
progress_n_dil_in = 0
progress_n_dil_out = 0
progress_n_nuc = 0
if (env_state_ptr_f%elapsed_time < run_part_opt_ptr_f%del_t) then
call mosaic_init(env_state_ptr_f, aero_data_ptr_f, run_part_opt_ptr_f%del_t, &
run_part_opt_ptr_f%do_optical)
if (run_part_opt_ptr_f%t_output > 0) then
call output_state(run_part_opt_ptr_f%output_prefix, &
run_part_opt_ptr_f%output_type, aero_data_ptr_f, aero_state_ptr_f, gas_data_ptr_f, &
gas_state_ptr_f, env_state_ptr_f, 1, .0d0, run_part_opt_ptr_f%del_t, &
run_part_opt_ptr_f%i_repeat, run_part_opt_ptr_f%record_removals, &
run_part_opt_ptr_f%do_optical, run_part_opt_ptr_f%uuid)
end if
end if
call run_part_timeblock(scenario_ptr_f, env_state_ptr_f, aero_data_ptr_f, aero_state_ptr_f, &
gas_data_ptr_f, gas_state_ptr_f, run_part_opt_ptr_f, camp_core_ptr_f, photolysis_ptr_f, &
i_time, i_next, t_start, last_output_time, &
last_progress_time, i_output, progress_n_samp, progress_n_coag, &
progress_n_emit, progress_n_dil_in, progress_n_dil_out, &
progress_n_nuc)
end subroutine
end module