Skip to content

Commit

Permalink
tiny tweaks to quiet compiler warnings (#1491)
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren authored Mar 12, 2024
1 parent 7861ec1 commit bf29f21
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 31 deletions.
46 changes: 24 additions & 22 deletions Source/BoundaryConditions/ABLMost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ ABLMost::compute_most_bcs (const int& lev,
// Valid CC box
Box vbx = mfi.validbox(); vbx.makeSlab(2,klo-1);

#ifdef ERF_EXPLICIT_MOST_STRESS
Box vbxx = surroundingNodes(vbx,0);
Box vbxy = surroundingNodes(vbx,1);
#endif

// Get field arrays
const auto cons_arr = mfs[Vars::cons]->array(mfi);
Expand All @@ -221,7 +223,7 @@ ABLMost::compute_most_bcs (const int& lev,
const auto *const u_mean = m_ma.get_average(lev,0);
const auto *const v_mean = m_ma.get_average(lev,1);
const auto *const t_mean = m_ma.get_average(lev,2);
const auto *const q_mean = m_ma.get_average(lev,3);
// const auto *const q_mean = m_ma.get_average(lev,3);
const auto *const u_mag_mean = m_ma.get_average(lev,4);

const auto um_arr = u_mean->array(mfi);
Expand Down Expand Up @@ -291,16 +293,16 @@ ABLMost::compute_most_bcs (const int& lev,
Real dz = (zphys_arr) ? ( zphys_arr(i,j,klo) - zphys_arr(i,j,klo-1) ) : dz_no_terrain;
#ifdef ERF_EXPLICIT_MOST_STRESS
Real dz1 = (zphys_arr) ? ( zphys_arr(i,j,klo+1) - zphys_arr(i,j,klo) ) : dz_no_terrain;
Real Qflux = flux_comp.compute_q_flux(i, j, k, n, icomp, dz, dz1,
cons_arr, velx_arr, vely_arr,
umm_arr, tm_arr, u_star_arr, q_star_arr, t_surf_arr,
dest_arr);
//Real Qflux = flux_comp.compute_q_flux(i, j, k, n, icomp, dz, dz1,
// cons_arr, velx_arr, vely_arr,
// umm_arr, tm_arr, u_star_arr, q_star_arr, t_surf_arr,
// dest_arr);
#else
Real Qflux = flux_comp.compute_q_flux(i, j, k, n, icomp, dz,
cons_arr, velx_arr, vely_arr,
eta_arr,
umm_arr, tm_arr, u_star_arr, q_star_arr, t_surf_arr,
dest_arr);
//Real Qflux = flux_comp.compute_q_flux(i, j, k, n, icomp, dz,
// cons_arr, velx_arr, vely_arr,
// eta_arr,
// umm_arr, tm_arr, u_star_arr, q_star_arr, t_surf_arr,
// dest_arr);
#endif
});
}
Expand All @@ -324,11 +326,11 @@ ABLMost::compute_most_bcs (const int& lev,
if (t31_arr) t31_arr(i,j,klo) = -stressx;
}
#else
Real stressx = flux_comp.compute_u_flux(i, j, k, icomp, dz,
cons_arr, velx_arr, vely_arr,
eta_arr,
umm_arr, um_arr, u_star_arr,
dest_arr);
//Real stressx = flux_comp.compute_u_flux(i, j, k, icomp, dz,
// cons_arr, velx_arr, vely_arr,
// eta_arr,
// umm_arr, um_arr, u_star_arr,
// dest_arr);
#endif
});

Expand All @@ -351,11 +353,11 @@ ABLMost::compute_most_bcs (const int& lev,
if (t32_arr) t32_arr(i,j,klo) = -stressy;
}
#else
Real stressy = flux_comp.compute_v_flux(i, j, k, icomp, dz,
cons_arr, velx_arr, vely_arr,
eta_arr,
umm_arr, vm_arr, u_star_arr,
dest_arr);
//Real stressy = flux_comp.compute_v_flux(i, j, k, icomp, dz,
// cons_arr, velx_arr, vely_arr,
// eta_arr,
// umm_arr, vm_arr, u_star_arr,
// dest_arr);
#endif
});
}
Expand All @@ -371,9 +373,9 @@ ABLMost::time_interp_sst (const int& lev,
Real dT = m_bdy_time_interval;
Real time_since_start = time - m_start_bdy_time;
int n_time = static_cast<int>( time_since_start / dT);
Real alpha = (time_since_start - n_time * dT) / dT;
amrex::Real alpha = (time_since_start - n_time * dT) / dT;
AMREX_ALWAYS_ASSERT( alpha >= 0. && alpha <= 1.0);
Real oma = 1.0 - alpha;
amrex::Real oma = 1.0 - alpha;
AMREX_ALWAYS_ASSERT( (n_time >= 0) && (n_time < (m_sst_lev[lev].size()-1)));

// Populate t_surf
Expand Down
6 changes: 6 additions & 0 deletions Source/BoundaryConditions/MOSTAverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ MOSTAverage::set_k_indices_N()
Real m_zhi = m_geom[lev].ProbHi(2);
Real m_dz = m_geom[lev].CellSize(2);

amrex::ignore_unused(m_zhi);

AMREX_ASSERT_WITH_MESSAGE(m_zref >= m_zlo + 0.5 * m_dz,
"Query point must be past first z-cell!");

Expand Down Expand Up @@ -311,6 +313,7 @@ MOSTAverage::set_k_indices_T()
// Capture for device
Real d_zref = m_zref;
Real d_radius = m_radius;
amrex::ignore_unused(d_radius);

// Specify z_ref & compute k_indx (z_ref takes precedence)
if (read_z) {
Expand Down Expand Up @@ -411,6 +414,7 @@ MOSTAverage::set_norm_indices_T()
}

// Destination cell must be contained on the current process!
amrex::ignore_unused(gpbx);
AMREX_ASSERT_WITH_MESSAGE(gpbx.contains(i_arr(i,j,k),j_arr(i,j,k),k_arr(i,j,k)),
"Query index outside of proc domain!");
});
Expand Down Expand Up @@ -456,6 +460,7 @@ MOSTAverage::set_z_positions_T()

// Destination position must be contained on the current process!
Real pos[] = {x_pos_arr(i,j,k),y_pos_arr(i,j,k),0.5*dx[2]};
amrex::ignore_unused(pos);
AMREX_ASSERT_WITH_MESSAGE( grb.contains(&pos[0]),
"Query point outside of proc domain!");
});
Expand Down Expand Up @@ -516,6 +521,7 @@ MOSTAverage::set_norm_positions_T()

// Destination position must be contained on the current process!
Real pos[] = {x_pos_arr(i,j,k),y_pos_arr(i,j,k),0.5*dx[2]};
amrex::ignore_unused(pos);
AMREX_ASSERT_WITH_MESSAGE( grb.contains(&pos[0]),
"Query point outside of proc domain!");
});
Expand Down
46 changes: 41 additions & 5 deletions Source/IO/ERF_WriteScalarProfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,46 @@ ERF::sum_integrated_quantities(Real time)
int datwidth = 14;
int datprecision = 6;

// Single level sum
Real mass_sl;

// Multilevel sums
Real mass_ml = 0.0;
Real rhth_ml = 0.0;
Real scal_ml = 0.0;

// Level 0 sums
Real mass_sl = volWgtSumMF(0,vars_new[0][Vars::cons], Rho_comp,*mapfac_m[0],false,false);
#if 1
mass_sl = volWgtSumMF(0,vars_new[0][Vars::cons],Rho_comp,*mapfac_m[0],false,false);
for (int lev = 0; lev <= finest_level; lev++) {
mass_ml += volWgtSumMF(lev,vars_new[lev][Vars::cons],Rho_comp,*mapfac_m[lev],false,true);
}
#else
for (int lev = 0; lev <= finest_level; lev++) {
MultiFab pert_dens(vars_new[lev][Vars::cons].boxArray(),
vars_new[lev][Vars::cons].DistributionMap(),
1,0);
MultiFab r_hse (base_state[lev], make_alias, 0, 1); // r_0 is first component
for ( MFIter mfi(pert_dens,TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.tilebox();
const Array4<Real >& pert_dens_arr = pert_dens.array(mfi);
const Array4<Real const>& S_arr = vars_new[lev][Vars::cons].const_array(mfi);
const Array4<Real const>& r0_arr = r_hse.const_array(mfi);
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
pert_dens_arr(i, j, k, 0) = S_arr(i,j,k,Rho_comp) - r0_arr(i,j,k);
});
}
if (lev == 0) {
mass_sl = volWgtSumMF(0,pert_dens,0,*mapfac_m[0],false,false);
}
mass_ml += volWgtSumMF(lev,pert_dens,0,*mapfac_m[lev],false,true);
} // lev
#endif

Real rhth_sl = volWgtSumMF(0,vars_new[0][Vars::cons], RhoTheta_comp,*mapfac_m[0],false,false);
Real scal_sl = volWgtSumMF(0,vars_new[0][Vars::cons],RhoScalar_comp,*mapfac_m[0],false,false);

for (int lev = 0; lev <= finest_level; lev++) {
mass_ml += volWgtSumMF(lev,vars_new[lev][Vars::cons], Rho_comp,*mapfac_m[lev],false,true);
rhth_ml += volWgtSumMF(lev,vars_new[lev][Vars::cons], RhoTheta_comp,*mapfac_m[lev],false,true);
scal_ml += volWgtSumMF(lev,vars_new[lev][Vars::cons],RhoScalar_comp,*mapfac_m[lev],false,true);
}
Expand Down Expand Up @@ -80,11 +108,19 @@ ERF::sum_integrated_quantities(Real time)

amrex::Print() << '\n';
if (finest_level == 0) {
amrex::Print() << "TIME= " << time << " MASS = " << mass_sl << '\n';
#if 1
amrex::Print() << "TIME= " << time << " MASS = " << mass_sl << '\n';
#else
amrex::Print() << "TIME= " << time << " PERT MASS = " << mass_sl << '\n';
#endif
amrex::Print() << "TIME= " << time << " RHO THETA = " << rhth_sl << '\n';
amrex::Print() << "TIME= " << time << " RHO SCALAR = " << scal_sl << '\n';
} else {
amrex::Print() << "TIME= " << time << " MASS SL/ML = " << mass_sl << " " << mass_ml << '\n';
#if 1
amrex::Print() << "TIME= " << time << " MASS SL/ML = " << mass_sl << " " << mass_ml << '\n';
#else
amrex::Print() << "TIME= " << time << " PERT MASS SL/ML = " << mass_sl << " " << mass_ml << '\n';
#endif
amrex::Print() << "TIME= " << time << " RHO THETA SL/ML = " << rhth_sl << " " << rhth_ml << '\n';
amrex::Print() << "TIME= " << time << " RHO SCALAR SL/ML = " << scal_sl << " " << scal_ml << '\n';
}
Expand Down
10 changes: 6 additions & 4 deletions Source/TimeIntegration/ERF_make_buoyancy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ void make_buoyancy (Vector<MultiFab>& S_data,
// ******************************************************************************************
if (solverChoice.moisture_type != MoistureType::None) {

if (solverChoice.moisture_type == MoistureType::Kessler_NoRain)
if (solverChoice.moisture_type == MoistureType::Kessler_NoRain) {
AMREX_ALWAYS_ASSERT(solverChoice.buoyancy_type == 1);
}

if (solverChoice.moisture_type == MoistureType::SAM)
if (solverChoice.moisture_type == MoistureType::SAM) {
AMREX_ALWAYS_ASSERT(solverChoice.buoyancy_type == 1);
}

if (solverChoice.buoyancy_type == 1) {

Expand All @@ -159,7 +161,7 @@ void make_buoyancy (Vector<MultiFab>& S_data,
// Base state density
const Array4<const Real>& r0_arr = r0->const_array(mfi);

ParallelFor(tbz, [=, moisture_type=solverChoice.moisture_type] AMREX_GPU_DEVICE (int i, int j, int k)
ParallelFor(tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
Real rhop_hi = cell_data(i,j,k ,Rho_comp) + cell_data(i,j,k ,RhoQ1_comp) + cell_data(i,j,k ,RhoQ2_comp) - r0_arr(i,j,k );
Real rhop_lo = cell_data(i,j,k-1,Rho_comp) + cell_data(i,j,k-1,RhoQ1_comp) + cell_data(i,j,k-1,RhoQ2_comp) - r0_arr(i,j,k-1);
Expand Down Expand Up @@ -263,7 +265,7 @@ void make_buoyancy (Vector<MultiFab>& S_data,
qp_minus - qp_d_ptr[k-1] )
+ (tempm3d-tempm1d)/tempm1d*(Real(1.0) + Real(0.61)*qv_d_ptr[k-1]-qc_d_ptr[k-1]-qp_d_ptr[k-1]);

} else if (buoyancy_type == 4) {
} else { // (buoyancy_type == 4)
qplus = 0.61 * ( qv_plus - qv_d_ptr[k] ) -
( qc_plus - qc_d_ptr[k] +
qp_plus - qp_d_ptr[k] )
Expand Down

0 comments on commit bf29f21

Please sign in to comment.