Skip to content

Commit 17669e8

Browse files
committed
save
1 parent 05445fe commit 17669e8

File tree

2 files changed

+33
-59
lines changed

2 files changed

+33
-59
lines changed

src/mam4xx/mo_sethet.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void calc_precip_rescale(
7676
total_pos = 0.0;
7777
// Kokkos::parallel_for(
7878
// Kokkos::ThreadVectorRange(team, pver), KOKKOS_LAMBDA(int kk) { //team vector range
79-
79+
8080
// });
8181

8282
Kokkos::parallel_reduce(
@@ -144,7 +144,7 @@ void gas_washout(
144144
// ... calculate the saturation concentration eqca
145145
//-----------------------------------------------------------------
146146
Kokkos::parallel_for(
147-
Kokkos::TeamVectorRange(team, plev, pver_loc), [&](int k) {
147+
Kokkos::TeamVectorRange(team, plev, pver_loc), [&](int k) {
148148
// cal washout below cloud
149149
xeqca(k) = xgas(k) /
150150
(xliq_ik * avo2 + 1.0 / (xhen_i(k) * const0 * tfld_i(k))) *
@@ -166,14 +166,14 @@ void gas_washout(
166166
allca(0) = 0.0;
167167
for (int kk = plev; kk < pver; kk++) {
168168
Kokkos::single(Kokkos::PerTeam(team),
169-
[=]() {
169+
[=]() {
170170
allca(0) += xca(kk);
171171
if (allca(0) < xeqca(kk)) {
172172
xgas(kk) = haero::max(xgas(kk) - xca(kk), 0.0);
173173
}
174174
});
175-
}
176-
175+
}
176+
177177
} // end subroutine gas_washout
178178

179179
//=================================================================================
@@ -222,7 +222,7 @@ void sethet(
222222
const ColumnView qin[gas_pcnst], // xported species [vmr] //in
223223
// working variables
224224
const ColumnView &xeqca,
225-
const ColumnView &xca,
225+
const ColumnView &xca,
226226
const ColumnView &allca, //total of ca between level plev and kk [#/cm3]
227227
const ColumnView
228228
&t_factor, // temperature factor to calculate henry's law parameters
@@ -314,7 +314,7 @@ void sethet(
314314
});
315315

316316
//thread ranges are within a team range
317-
//team range
317+
//team range
318318

319319
for (int mm = 0; mm < gas_wetdep_cnt; mm++) { // for w/ teamthreadrange
320320
int mm2 = wetdep_map[mm];
@@ -465,7 +465,7 @@ void sethet(
465465

466466
for (int kk = ktop; kk < pver; kk++) {
467467
bool skip = false;
468-
Kokkos::printf("kk = %d", kk);
468+
// Kokkos::printf("kk = %d", kk);
469469
Kokkos::parallel_for(Kokkos::TeamVectorRange(team, gas_pcnst_loc),
470470
[&](int mm) {
471471
if (rain(kk) <= 0.0) {
@@ -474,7 +474,7 @@ void sethet(
474474
}
475475
});
476476
if (skip) {
477-
Kokkos::printf("skipping");
477+
// Kokkos::printf("skipping");
478478
continue;
479479
}
480480

@@ -528,4 +528,4 @@ void sethet(
528528

529529
} // namespace mo_sethet
530530
} // namespace mam4
531-
#endif
531+
#endif

src/validation/mo_sethet/sethet.cpp

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,6 @@ void sethet(Ensemble *ensemble) {
8080
ColumnView xgas2, xgas3, delz, xh2o2, xso2, xliq, rain, precip, xhen_h2o2,
8181
xhen_hno3, xhen_so2, t_factor, xk0_hno3, xk0_so2, so2_diss;
8282

83-
// initialize internal veriables
84-
std::vector<Real> vector0(pver, 0);
85-
auto xgas2_host = View1DHost(vector0.data(), pver);
86-
auto xgas3_host = View1DHost(vector0.data(), pver);
87-
auto delz_host = View1DHost(vector0.data(), pver);
88-
auto xh2o2_host = View1DHost(vector0.data(), pver);
89-
auto xso2_host = View1DHost(vector0.data(), pver);
90-
auto xliq_host = View1DHost(vector0.data(), pver);
91-
auto rain_host = View1DHost(vector0.data(), pver);
92-
auto precip_host = View1DHost(vector0.data(), pver);
93-
auto xhen_h2o2_host = View1DHost(vector0.data(), pver);
94-
auto xhen_hno3_host = View1DHost(vector0.data(), pver);
95-
auto xhen_so2_host = View1DHost(vector0.data(), pver);
96-
auto t_factor_host = View1DHost(vector0.data(), pver);
97-
auto xk0_hno3_host = View1DHost(vector0.data(), pver);
98-
auto xk0_so2_host = View1DHost(vector0.data(), pver);
99-
auto so2_diss_host = View1DHost(vector0.data(), pver);
100-
10183
xgas2 = haero::testing::create_column_view(pver);
10284
xgas3 = haero::testing::create_column_view(pver);
10385
delz = haero::testing::create_column_view(pver);
@@ -114,27 +96,26 @@ void sethet(Ensemble *ensemble) {
11496
xk0_so2 = haero::testing::create_column_view(pver);
11597
so2_diss = haero::testing::create_column_view(pver);
11698

117-
Kokkos::deep_copy(xgas2, xgas2_host);
118-
Kokkos::deep_copy(xgas3, xgas3_host);
119-
Kokkos::deep_copy(delz, delz_host);
120-
Kokkos::deep_copy(xh2o2, xh2o2_host);
121-
Kokkos::deep_copy(xso2, xso2_host);
122-
Kokkos::deep_copy(xliq, xliq_host);
123-
Kokkos::deep_copy(rain, rain_host);
124-
Kokkos::deep_copy(precip, precip_host);
125-
Kokkos::deep_copy(xhen_h2o2, xhen_h2o2_host);
126-
Kokkos::deep_copy(xhen_hno3, xhen_hno3_host);
127-
Kokkos::deep_copy(xhen_so2, xhen_so2_host);
128-
Kokkos::deep_copy(t_factor, t_factor_host);
129-
Kokkos::deep_copy(xk0_hno3, xk0_hno3_host);
130-
Kokkos::deep_copy(xk0_so2, xk0_so2_host);
131-
Kokkos::deep_copy(so2_diss, so2_diss_host);
99+
Kokkos::deep_copy(xgas2, 0.0);
100+
Kokkos::deep_copy(xgas3, 0.0);
101+
Kokkos::deep_copy(delz, 0.0);
102+
Kokkos::deep_copy(xh2o2, 0.0);
103+
Kokkos::deep_copy(xso2, 0.0);
104+
Kokkos::deep_copy(xliq, 0.0);
105+
Kokkos::deep_copy(rain, 0.0);
106+
Kokkos::deep_copy(precip, 0.0);
107+
Kokkos::deep_copy(xhen_h2o2, 0.0);
108+
Kokkos::deep_copy(xhen_hno3, 0.0);
109+
Kokkos::deep_copy(xhen_so2, 0.0);
110+
Kokkos::deep_copy(t_factor, 0.0);
111+
Kokkos::deep_copy(xk0_hno3, 0.0);
112+
Kokkos::deep_copy(xk0_so2, 0.0);
113+
Kokkos::deep_copy(so2_diss, 0.0);
132114

133115
ColumnView het_rates[gas_pcnst];
134116
ColumnView tmp_hetrates[gas_pcnst];
135117
ColumnView qin[gas_pcnst];
136118
View1DHost het_rates_host[gas_pcnst];
137-
View1DHost tmp_hetrates_host[gas_pcnst];
138119
View1DHost qin_host[gas_pcnst];
139120

140121
for (int mm = 0; mm < gas_pcnst; ++mm) {
@@ -143,45 +124,38 @@ void sethet(Ensemble *ensemble) {
143124
qin[mm] = haero::testing::create_column_view(pver);
144125

145126
het_rates_host[mm] = View1DHost("het_rates_host", pver);
146-
tmp_hetrates_host[mm] = View1DHost("tmp_hetrates_host", pver);
147127
qin_host[mm] = View1DHost("qin_host", pver);
148128
}
149129

150130
int count = 0;
151131
for (int mm = 0; mm < gas_pcnst; ++mm) {
152132
for (int kk = 0; kk < pver; ++kk) {
153-
het_rates_host[mm](kk) = 0.0;
154-
tmp_hetrates_host[mm](kk) = 0.0;
155133
qin_host[mm](kk) = qin_in[count];
156134
count++;
157135
}
158136
}
159137

160138
// transfer data to GPU.
161139
for (int mm = 0; mm < gas_pcnst; ++mm) {
162-
Kokkos::deep_copy(het_rates[mm], het_rates_host[mm]);
163-
Kokkos::deep_copy(tmp_hetrates[mm], tmp_hetrates_host[mm]);
140+
Kokkos::deep_copy(het_rates[mm], 0.0);
141+
Kokkos::deep_copy(tmp_hetrates[mm], 0.0);
164142
Kokkos::deep_copy(qin[mm], qin_host[mm]);
165143
}
166144

167145
// initialize internal veriables
168-
ColumnView xeqca, xca, allca;
169-
auto xeqca_host = View1DHost(vector0.data(), pver);
170-
auto xca_host = View1DHost(vector0.data(), pver);
171-
auto allca_host = View1DHost("allca_host", 1);
146+
ColumnView xeqca, xca;
147+
View1D allca("allca", 1);
172148
xeqca = haero::testing::create_column_view(pver);
173149
xca = haero::testing::create_column_view(pver);
174-
allca = haero::testing::create_column_view(1);
175-
Kokkos::deep_copy(xeqca, xeqca_host);
176-
Kokkos::deep_copy(xca, xca_host);
177-
Kokkos::deep_copy(allca, allca_host);
150+
Kokkos::deep_copy(xeqca, 0.0);
151+
Kokkos::deep_copy(xca, 0.0);
178152

179153
auto team_policy = ThreadTeamPolicy(1u, Kokkos::AUTO);
180154
Kokkos::parallel_for(
181155
team_policy, KOKKOS_LAMBDA(const ThreadTeam &team) {
182156
mo_sethet::sethet(
183157
team, het_rates, rlat, press, zmid, phis, tfld, cmfdqr, nrain,
184-
nevapr, delt, xhnm, qin, xeqca, xca, allca, t_factor, xk0_hno3,
158+
nevapr, delt, xhnm, qin, xeqca, xca, allca, t_factor, xk0_hno3,
185159
xk0_so2, so2_diss,
186160
xgas2, xgas3, delz, xh2o2, xso2, xliq, rain, precip, xhen_h2o2,
187161
xhen_hno3, xhen_so2, tmp_hetrates, spc_h2o2_ndx, spc_so2_ndx,
@@ -203,4 +177,4 @@ void sethet(Ensemble *ensemble) {
203177

204178
output.set("het_rates", het_rates_out);
205179
});
206-
}
180+
}

0 commit comments

Comments
 (0)