Skip to content

Commit 3bd41e1

Browse files
committed
Fixing compilation errors in validation tests and applying clang-format.
1 parent ab0e899 commit 3bd41e1

File tree

11 files changed

+63
-76
lines changed

11 files changed

+63
-76
lines changed

src/mam4xx/gas_chem.hpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,17 @@ void imp_slv_inti(Real epsilon[clscnt4]) {
7878
}
7979
}
8080
template <typename VectorType>
81-
KOKKOS_INLINE_FUNCTION
82-
void newton_raphson_iter(const Real dti, const Real lin_jac[nzcnt],
83-
const Real lrxt[rxntot],
84-
const Real lhet[gas_pcnst], // in
85-
const Real iter_invariant[clscnt4], // in
86-
const bool factor[itermax],
87-
const int permute_4[gas_pcnst],
88-
const int clsmap_4[gas_pcnst], VectorType& lsol,
89-
Real solution[clscnt4], // inout
90-
bool converged[clscnt4], bool &convergence, // out
91-
Real prod[clscnt4], Real loss[clscnt4],
92-
Real max_delta[clscnt4],
93-
// work array
94-
Real epsilon[clscnt4]) {
81+
KOKKOS_INLINE_FUNCTION void newton_raphson_iter(
82+
const Real dti, const Real lin_jac[nzcnt], const Real lrxt[rxntot],
83+
const Real lhet[gas_pcnst], // in
84+
const Real iter_invariant[clscnt4], // in
85+
const bool factor[itermax], const int permute_4[gas_pcnst],
86+
const int clsmap_4[gas_pcnst], VectorType &lsol,
87+
Real solution[clscnt4], // inout
88+
bool converged[clscnt4], bool &convergence, // out
89+
Real prod[clscnt4], Real loss[clscnt4], Real max_delta[clscnt4],
90+
// work array
91+
Real epsilon[clscnt4]) {
9592

9693
// dti := 1 / dt
9794
// lrxt := reaction rates in 1D array [1/cm^3/s]
@@ -240,13 +237,13 @@ void newton_raphson_iter(const Real dti, const Real lin_jac[nzcnt],
240237
} // end nr_iter loop
241238
} // newton_raphson_iter() function
242239
template <typename VectorType>
243-
KOKKOS_INLINE_FUNCTION
244-
void imp_sol(VectorType& base_sol, // inout - species mixing ratios [vmr]
245-
const Real reaction_rates[rxntot], const Real het_rates[gas_pcnst],
246-
const Real extfrc[extcnt], const Real &delt,
247-
const int permute_4[gas_pcnst], const int clsmap_4[gas_pcnst],
248-
const bool factor[itermax], Real epsilon[clscnt4],
249-
Real prod_out[clscnt4], Real loss_out[clscnt4]) {
240+
KOKKOS_INLINE_FUNCTION void
241+
imp_sol(VectorType &base_sol, // inout - species mixing ratios [vmr]
242+
const Real reaction_rates[rxntot], const Real het_rates[gas_pcnst],
243+
const Real extfrc[extcnt], const Real &delt,
244+
const int permute_4[gas_pcnst], const int clsmap_4[gas_pcnst],
245+
const bool factor[itermax], Real epsilon[clscnt4],
246+
Real prod_out[clscnt4], Real loss_out[clscnt4]) {
250247

251248
// ---------------------------------------------------------------------------
252249
// ... imp_sol advances the volumetric mixing ratio

src/mam4xx/gas_chem_mechanism.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ void adjrxt(Real rate[rxntot], const Real inv[nfs], const Real m) {
8585
// concerning lines in linmat(), though it's difficult to tell if that results
8686
// in consistent units
8787
template <typename VectorType>
88-
KOKKOS_INLINE_FUNCTION
89-
void imp_prod_loss(Real prod[clscnt4], Real loss[clscnt4], VectorType& y,
90-
const Real rxt[rxntot], const Real het_rates[gas_pcnst]) {
88+
KOKKOS_INLINE_FUNCTION void
89+
imp_prod_loss(Real prod[clscnt4], Real loss[clscnt4], VectorType &y,
90+
const Real rxt[rxntot], const Real het_rates[gas_pcnst]) {
9191
const Real zero = 0;
9292
loss[0] = (+het_rates[1] + rxt[0] + rxt[2]) * (+y[1]);
9393
prod[0] = zero;

src/mam4xx/gas_phase_chemistry.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ using mam4::gas_chemistry::indexm;
3434
// performs gas phase chemistry calculations on a single level of a single
3535
// atmospheric column
3636
template <typename VectorType>
37-
KOKKOS_INLINE_FUNCTION
38-
void gas_phase_chemistry(
37+
KOKKOS_INLINE_FUNCTION void gas_phase_chemistry(
3938
// in
4039
const Real temp, const Real dt,
4140
const Real photo_rates[mam4::mo_photo::phtcnt], const Real extfrc[extcnt],

src/mam4xx/mam4_amicphys.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,9 +2113,8 @@ void get_gcm_tend_diags_from_subareas(
21132113

21142114
//--------------------------------------------------------------------------------
21152115
//--------------------------------------------------------------------------------
2116-
template<typename VectorType, typename VectorTypeModes>
2117-
KOKKOS_INLINE_FUNCTION
2118-
void modal_aero_amicphys_intr(
2116+
template <typename VectorType, typename VectorTypeModes>
2117+
KOKKOS_INLINE_FUNCTION void modal_aero_amicphys_intr(
21192118
// in
21202119
const AmicPhysConfig &config, const Real deltat, const Real temp,
21212120
const Real pmid, const Real pdel, const Real zm, const Real pblh,
@@ -2130,12 +2129,9 @@ void modal_aero_amicphys_intr(
21302129
const View2D &gas_aero_exchange_coagulation,
21312130
const View2D &gas_aero_exchange_renaming_cloud_borne,
21322131
// in
2133-
const VectorType& q_pregaschem,
2134-
const VectorType& q_precldchem,
2135-
const VectorType& qqcw_precldchem,
2136-
const VectorTypeModes& dgncur_a,
2137-
const VectorTypeModes& dgncur_awet,
2138-
const VectorTypeModes& wetdens_host) {
2132+
const VectorType &q_pregaschem, const VectorType &q_precldchem,
2133+
const VectorType &qqcw_precldchem, const VectorTypeModes &dgncur_a,
2134+
const VectorTypeModes &dgncur_awet, const VectorTypeModes &wetdens_host) {
21392135
// deltat: time step
21402136
// qq(ncol,pver,pcnst): current tracer mixing ratios (TMRs)
21412137
// these values are updated (so out /= in)

src/mam4xx/mo_gas_phase_chemdr.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ KOKKOS_INLINE_FUNCTION
3333
void mmr2vmr_col(const ThreadTeam &team, const haero::Atmosphere &atm,
3434
const mam4::Prognostics &progs,
3535
const Real adv_mass_kg_per_moles[gas_pcnst],
36-
const int offset_aerosol,
37-
const View2D vmr_col) {
36+
const int offset_aerosol, const View2D vmr_col) {
3837
// Make a local copy of nlev to avoid the identifier "mam4::nlev" being
3938
// undefined in device code.
4039
constexpr int nlev_local = nlev;
@@ -50,7 +49,7 @@ void mmr2vmr_col(const ThreadTeam &team, const haero::Atmosphere &atm,
5049
// output (vmr)
5150
mam4::microphysics::mmr2vmr(qq, adv_mass_kg_per_moles, vmr);
5251
for (int i = 0; i < gas_pcnst; ++i) {
53-
vmr_col(kk,i) = vmr[i];
52+
vmr_col(kk, i) = vmr[i];
5453
}
5554
});
5655
}

src/mam4xx/mo_photo.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,14 @@ KOKKOS_INLINE_FUNCTION
174174
void setcol(const ThreadTeam &team, const Real o3_col_deltas[mam4::nlev + 1],
175175
ColumnView &o3_col_dens) {
176176
constexpr int nlev = mam4::nlev;
177-
Kokkos::parallel_for(
178-
Kokkos::TeamThreadRange(team, nlev),
179-
[&](int kk) {
180-
Kokkos::parallel_reduce(
181-
Kokkos::ThreadVectorRange(team, kk+1),
182-
[&](int i, Real &lsum) {
183-
lsum += 0.5 * (o3_col_deltas[i] + o3_col_deltas[i+1]);
184-
},
185-
o3_col_dens(kk));
186-
});
177+
Kokkos::parallel_for(Kokkos::TeamThreadRange(team, nlev), [&](int kk) {
178+
Kokkos::parallel_reduce(
179+
Kokkos::ThreadVectorRange(team, kk + 1),
180+
[&](int i, Real &lsum) {
181+
lsum += 0.5 * (o3_col_deltas[i] + o3_col_deltas[i + 1]);
182+
},
183+
o3_col_dens(kk));
184+
});
187185
}
188186

189187
KOKKOS_INLINE_FUNCTION

src/mam4xx/mo_sethet.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,18 @@ int get_total_work_len_sethet() {
204204
KOKKOS_INLINE_FUNCTION
205205
void sethet_detail(
206206
const ThreadTeam &team,
207-
const View2D &het_rates, // rainout rates [1/s] //out
208-
const Real rlat, // latitude in radians for columns
209-
const ConstColumnView &press, // pressure [pascals] //in
210-
const ConstColumnView &zmid, // midpoint geopot [km] //in
211-
const Real phis, // surf geopotential //in
212-
const ConstColumnView &tfld, // temperature [K] //in
213-
const ColumnView &cmfdqr, // dq/dt for convection [kg/kg/s] //in
214-
const ConstColumnView &nrain, // stratoform precip [kg/kg/s] //in
215-
const ConstColumnView &nevapr, // evaporation [kg/kg/s] //in
216-
const Real delt, // time step [s] //in
217-
const View2D &invariants, // total atms density [cm^-3] //in
218-
const View2D qin, // xported species [vmr] //in
207+
const View2D &het_rates, // rainout rates [1/s] //out
208+
const Real rlat, // latitude in radians for columns
209+
const ConstColumnView &press, // pressure [pascals] //in
210+
const ConstColumnView &zmid, // midpoint geopot [km] //in
211+
const Real phis, // surf geopotential //in
212+
const ConstColumnView &tfld, // temperature [K] //in
213+
const ColumnView &cmfdqr, // dq/dt for convection [kg/kg/s] //in
214+
const ConstColumnView &nrain, // stratoform precip [kg/kg/s] //in
215+
const ConstColumnView &nevapr, // evaporation [kg/kg/s] //in
216+
const Real delt, // time step [s] //in
217+
const View2D &invariants, // total atms density [cm^-3] //in
218+
const View2D qin, // xported species [vmr] //in
219219
// working variables
220220
const ColumnView
221221
&t_factor, // temperature factor to calculate henry's law parameters
@@ -330,8 +330,8 @@ void sethet_detail(
330330
rain(kk) = mass_air * precip(kk) * invariants(kk, indexm) / mass_h2o;
331331
xliq(kk) =
332332
precip(kk) * delt * invariants(kk, indexm) / avo * mass_air * m3_2_cm3;
333-
xh2o2(kk) = qin(kk,spc_h2o2_ndx) * invariants(kk, indexm);
334-
xso2(kk) = qin(kk,spc_so2_ndx) * invariants(kk, indexm);
333+
xh2o2(kk) = qin(kk, spc_h2o2_ndx) * invariants(kk, indexm);
334+
xso2(kk) = qin(kk, spc_so2_ndx) * invariants(kk, indexm);
335335
});
336336
zsurf = m2km * phis * rga;
337337

@@ -498,10 +498,10 @@ void sethet(
498498
const Real phis, // surf geopotential //in
499499
const ColumnView &cmfdqr, // dq/dt for convection [kg/kg/s] //in
500500
const ConstColumnView &prain, // stratoform precip [kg/kg/s] //in
501-
const ConstColumnView &nevapr, // evaporation [kg/kg/s] //in
502-
const Real dt, // time step [s] //in
503-
const View2D &invariants, //
504-
const View2D& vmr, // xported species [vmr] //in
501+
const ConstColumnView &nevapr, // evaporation [kg/kg/s] //in
502+
const Real dt, // time step [s] //in
503+
const View2D &invariants, //
504+
const View2D &vmr, // xported species [vmr] //in
505505
// working variables
506506
const View1D &work) {
507507

src/validation/gas_chem/imp_prod_loss.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ void imp_prod_loss(Ensemble *ensemble) {
2525
const auto het_rates = input.get_array("het_rates");
2626
auto y = input.get_array("y");
2727

28-
imp_prod_loss(prod.data(), loss.data(), y.data(), rxt.data(),
29-
het_rates.data());
28+
imp_prod_loss(prod.data(), loss.data(), y, rxt.data(), het_rates.data());
3029
output.set("prod", prod);
3130
output.set("loss", loss);
3231
});

src/validation/gas_chem/imp_sol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void imp_sol(Ensemble *ensemble) {
3535
factor[i] = true;
3636
}
3737

38-
imp_sol(base_sol.data(), // ! species mixing ratios [vmr] & !
38+
imp_sol(base_sol, // ! species mixing ratios [vmr] & !
3939
reaction_rates.data(), het_rates.data(), extfrc.data(), delt,
4040
permute_4, clsmap_4, factor, epsilon, prod_out.data(),
4141
loss_out.data());

src/validation/gas_chem/newton_raphson_iter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void newton_raphson_iter(Ensemble *ensemble) {
4040
newton_raphson_iter(dti, lin_jac.data(), lrxt.data(),
4141
lhet.data(), // & ! in
4242
iter_invariant.data(), // & ! in
43-
factor, permute_4, clsmap_4, lsol.data(),
43+
factor, permute_4, clsmap_4, lsol,
4444
solution.data(), // & ! inout
4545
converged, convergence, // & ! out
4646
prod.data(), loss.data(), max_delta.data(),

0 commit comments

Comments
 (0)