Skip to content

Commit 6adef18

Browse files
committed
Missing sp(x) calls in pack/scalar operations
1 parent 1051159 commit 6adef18

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

components/eamxx/src/physics/p3/impl/p3_dsd2_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ KOKKOS_FUNCTION
1616
void Functions<S,D>::
1717
get_cloud_dsd2(
1818
const Spack& qc, Spack& nc, Spack& mu_c, const Spack& rho, Spack& nu,
19-
const view_dnu_table& dnu, Spack& lamc, Spack& cdist, Spack& cdist1,
19+
const view_dnu_table& dnu, Spack& lamc, Spack& cdist, Spack& cdist1,
2020
const Smask& context)
2121
{
2222
lamc.set(context , 0);
@@ -105,10 +105,10 @@ get_rain_dsd2 (
105105
lamr.set(qr_gt_small, cbrt(mass_to_d3_factor * nr_lim / qr));
106106

107107
// check for slope
108-
const auto lammax = (mu_r+1.)*sp(1.e+5);
108+
const auto lammax = (mu_r+sp(1.))*sp(1.e+5);
109109
//Below, 500 is inverse of max allowable number-weighted mean raindrop size=2mm
110110
//Since breakup is explicitly included, mean raindrop size can be relatively small
111-
const auto lammin = (mu_r+1.)*500;
111+
const auto lammin = (mu_r+sp(1.))*500;
112112

113113
// apply lambda limiters for rain
114114
const auto lt = qr_gt_small && (lamr < lammin);

components/eamxx/src/physics/p3/impl/p3_ice_classical_nucleation_impl.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ ::ice_classical_nucleation(
2424
constexpr Scalar pi = C::Pi;
2525
constexpr Scalar rho_h2o = C::RHO_H2O.value;
2626

27-
// TODO: Verify if qsmall can be unified with other "small" numeric literals
27+
// TODO: Verify if qsmall can be unified with other "small" numeric literals
2828
constexpr Scalar qsmall = 1.0e-18;
2929
constexpr Scalar piov3 = pi/3.0;
3030

3131
// TODO: Verify if 1.0e-18 can be unified with other "small" numeric literals
3232
constexpr Scalar mi0 = 4.0*piov3*900.0*1.0e-18; // BAD_CONSTANT!
33-
33+
3434
const Spack Zero(0.0);
3535
// minimum mass of new crystal due to freezing of cloud droplets done
3636
// externally (kg)
37-
37+
3838
const Scalar mi0l_min = (4.0/3.0)*pi*rho_h2o*(4.0e-6)*(4.0e-6)*(4.0e-6);
39-
Spack mi0l = qc_incld/ekat::max(nc_incld,1.0e6/rho);
39+
Spack mi0l = qc_incld/ekat::max(nc_incld,sp(1.0e6)/rho);
4040
mi0l = ekat::max(mi0l_min, mi0l);
41-
41+
4242
const auto mask = qc_incld > qsmall;
4343
switch (Iflag) {
4444
case 1: // cloud droplet immersion freezing
45-
ncheti_cnt.set(mask, frzimm*1.0e6/rho /* frzimm input is in [#/cm3] */ , Zero);
45+
ncheti_cnt.set(mask, frzimm*sp(1.0e6)/rho /* frzimm input is in [#/cm3] */ , Zero);
4646
qcheti_cnt.set(mask, ncheti_cnt*mi0l, Zero);
4747
break;
4848
case 2: // deposition freezing / contact freezing
49-
nicnt.set(mask, frzcnt*1.0e6/rho, Zero);
49+
nicnt.set(mask, frzcnt*sp(1.0e6)/rho, Zero);
5050
qicnt.set(mask, nicnt*mi0l, Zero);
51-
ninuc_cnt.set(mask, frzdep*1.0e6/rho, Zero);
51+
ninuc_cnt.set(mask, frzdep*sp(1.0e6)/rho, Zero);
5252
qinuc_cnt.set(mask, ninuc_cnt*mi0, Zero);
5353
break;
5454
default:

components/eamxx/src/physics/p3/tests/p3_evaporate_rain_unit_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct UnitWrap::UnitTest<D>::TestEvapSublPrecip : public UnitWrap::UnitTest<D>:
118118
//for case with lots of evap, make sure doesn't overdeplete qr_incld
119119
Functions::evaporate_rain(qr_incld,qc_incld,nr_incld,qi_incld,
120120
//qv -> qv*0.1 to encourage lots of rain evap
121-
cld_frac_l,cld_frac_r,qv*0.1,qv_prev,qv_sat_l,qv_sat_i,
121+
cld_frac_l,cld_frac_r,qv*sp(0.1),qv_prev,qv_sat_l,qv_sat_i,
122122
ab,abi,epsr,epsi_tot,t,t_prev,dqsdt,dt,
123123
qrtend,nrtend);
124124
REQUIRE( qrtend[0] <= qr_incld[0]/dt);

components/eamxx/src/physics/shoc/impl/shoc_compute_shoc_mix_shoc_length_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ ::compute_shoc_mix_shoc_length(
4545
Spack brunt_tmp(stable_mask, brunt(k));
4646

4747
// Define length scale for stable cells
48-
const auto length_tmp = ekat::sqrt(0.76*tk(k)/0.1/ekat::sqrt(brunt_tmp + 1.e-10));
48+
const auto length_tmp = ekat::sqrt(sp(0.76)*tk(k)/sp(0.1)/ekat::sqrt(brunt_tmp + sp(1.e-10)));
4949
// Limit the stability corrected length scale between 0.1*dz and dz
50-
const auto limited_len = ekat::min(dz_zt(k),ekat::max(0.1*dz_zt(k),length_tmp));
50+
const auto limited_len = ekat::min(dz_zt(k),ekat::max(sp(0.1)*dz_zt(k),length_tmp));
5151

5252
// Set length scale to vertical grid if unstable, otherwise the stability adjusted value.
5353
shoc_mix(k).set(stable_mask, limited_len, dz_zt(k));

components/eamxx/src/share/physics/eamxx_common_physics_functions_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ ScalarT PhysicsFunctions<DeviceT>::calculate_vmr_from_mmr(const Real& gas_mol_we
462462
using C = scream::physics::Constants<Real>;
463463
constexpr Real air_mol_weight = C::MWdry.value;
464464

465-
return mmr / (1.0 - qv) * air_mol_weight/gas_mol_weight;
465+
return mmr / (sp(1.0) - qv) * air_mol_weight/gas_mol_weight;
466466

467467
}
468468

@@ -490,7 +490,7 @@ ScalarT PhysicsFunctions<DeviceT>::calculate_mmr_from_vmr(const Real& gas_mol_we
490490
constexpr Real air_mol_weight = C::MWdry.value;
491491
const Real mol_weight_ratio = gas_mol_weight/air_mol_weight;
492492

493-
return mol_weight_ratio * vmr * (1.0 - qv);
493+
return mol_weight_ratio * vmr * (sp(1.0) - qv);
494494

495495
}
496496

components/eamxx/src/share/physics/tests/common_physics_functions_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void run(std::mt19937_64& engine)
303303
p = pdf_pres(engine);
304304
const auto exner1 = PF::exner_function(p);
305305
const auto exner2 = PF::exner_function(p/2);
306-
const auto factor = pow(2.0,Rd*inv_cp);
306+
const auto factor = std::pow(sp(2.0),Rd*inv_cp);
307307
REQUIRE( Check::approx_equal(exner1,factor*exner2,test_tol) );
308308

309309
// Potential temperature property tests:

components/eamxx/src/share/util/tests/combine_ops_tests.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,9 @@ TEST_CASE ("combine_ops") {
3434
combine<Replace>(two,x,1,0);
3535
REQUIRE ( (x==two).all() );
3636

37-
combine<Update>(two,x,2.0,1.0);
37+
combine<Update>(two,x,sp(2.0),sp(1.0));
3838
REQUIRE ( (x==six).all() );
39-
combine<Update,true>(fv,x,2.0,1.0);
40-
if (not (x==six).all() ) {
41-
std::cout << "x: " << x << "\n";
42-
std::cout << " x[0]: " << std::setprecision(18) << x[0] << "\n";
43-
std::cout << "fv[0]: " << std::setprecision(18) << fv[0] << "\n";
44-
}
39+
combine<Update,true>(fv,x,sp(2.0),sp(1.0));
4540
REQUIRE ( (x==six).all() );
4641

4742
x = two;

0 commit comments

Comments
 (0)