Skip to content

Commit

Permalink
Fix remaining issues with bounds and unused vars.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Lattanzi committed Nov 13, 2024
1 parent ee99c78 commit b3b4c1c
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions Source/Initialization/ERF_Metgrid_utils.H
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ lagrange_setup (char var_type,
{
int ksta = kl-(order/2-1);
int kend = ksta+order;
int ksize = kend-ksta;
#ifndef AMREX_USE_GPU
int ksize = kend-ksta;
if (debug) amrex::Print() << " (1a) new_x=" << new_x_z[new_k] << " new_x_p=" << new_x_p[new_k] << " kl=" << kl << " kr=" << kr <<" ksta=" << ksta << " kend=" << kend << std::endl;
#endif
amrex::Real new_x;
Expand Down Expand Up @@ -264,8 +264,8 @@ lagrange_setup (char var_type,
{
int ksta = kl-order/2;
int kend = ksta+order;
int ksize = kend-ksta;
#ifndef AMREX_USE_GPU
int ksize = kend-ksta;
if (debug) amrex::Print() << "new_k=" << new_k << " (1b) new_x=" << new_x_z[new_k] << " new_x_p=" << new_x_p[new_k] << " kl=" << kl << " kr=" << kr <<" ksta=" << ksta << " kend=" << kend << std::endl;
#endif
amrex::Real new_x;
Expand Down Expand Up @@ -294,12 +294,14 @@ lagrange_setup (char var_type,
lagrange_interp(order, orig_x_sub_p, orig_y_sub_p, new_x, new_y_r);
}
new_y[new_k] = 0.5*(new_y_l+new_y_r);
#ifndef AMREX_USE_GPU
if (debug) amrex::Print() << " new_y=" << new_y[new_k] << std::endl;
#endif
} else if ((kl-(order/2-1) >= 0) && (kr+order/2 <= orig_n-1)) {
int ksta = kl-(order/2-1);
int kend = ksta+order;
int ksize = kend-ksta;
#ifndef AMREX_USE_GPU
int ksize = kend-ksta;
if (debug) amrex::Print() << " (2) new_x=" << new_x_z[new_k] << " new_x_p=" << new_x_p[new_k] << " kl=" << kl << " kr=" << kr <<" ksta=" << ksta << " kend=" << kend << std::endl;
#endif
amrex::Real new_x;
Expand All @@ -326,12 +328,14 @@ lagrange_setup (char var_type,
}
#endif
lagrange_interp(order, orig_x_sub_p, orig_y_sub_p, new_x, new_y[new_k]);
#ifndef AMREX_USE_GPU
if (debug) amrex::Print() << " new_y=" << new_y[new_k] << std::endl;
#endif
} else if ((kl-order/2 >= 0) && (kr+(order/2-1) <= orig_n-1)) {
int ksta = kl-order/2;
int kend = ksta+order;
int ksize = kend-ksta;
#ifndef AMREX_USE_GPU
int ksize = kend-ksta;
if (debug) amrex::Print() << " (3) new_x=" << new_x_z[new_k] << " new_x_p=" << new_x_p[new_k] << " kl=" << kl << " kr=" << kr <<" ksta=" << ksta << " kend=" << kend << std::endl;
#endif
amrex::Real new_x;
Expand Down Expand Up @@ -368,8 +372,8 @@ lagrange_setup (char var_type,
// Linear interpolation.
int ksta = kl;
int kend = kr;
int ksize = kend-ksta;
#ifndef AMREX_USE_GPU
int ksize = kend-ksta;
if (debug) amrex::Print() << " (4) new_x=" << new_x_z[new_k] << " new_x_p=" << new_x_p[new_k] << " kl=" << kl << " kr=" << kr <<" ksta=" << ksta << " kend=" << kend << std::endl;
#endif
amrex::Real new_x;
Expand Down Expand Up @@ -627,14 +631,9 @@ interpolate_column_metgrid (const bool& metgrid_use_below_sfc,
kend_order = count;
}

int ksta, kend;
int ksta(0), kend(0);
if (metgrid_use_below_sfc && metgrid_use_sfc) {
// Use all levels.
int count = 0;
for (int k=1; k < kend_order; k++) {
count++;
if (ordered_z_p[kend_order-1] == orig_z_p[k]) break;
}
ksta = 0;
kend = ksta+kend_order-1;
} else if (metgrid_use_below_sfc && !metgrid_use_sfc) {
Expand All @@ -650,26 +649,20 @@ interpolate_column_metgrid (const bool& metgrid_use_below_sfc,
ordered_z_p[k] = ordered_z_p[k+1];
ordered_data_p[k] = ordered_data_p[k+1];
}
int count = 0;
for (int k=0; k < kmax_orig; k++) {
count++;
if (orig_z_p[kmax_orig-1] == ordered_z_p[k]) break;
}
ksta = 0;
kend = ksta+kend_order-1;

kend = ksta+kend_order-2;
} else if (!metgrid_use_below_sfc && metgrid_use_sfc) {
// Use all levels above and including the surface.
int kcount = k_above_sfc-1-zap_below;
int count = 0;
int count = 0;
for (int k=0; k < kmax_orig; k++) {
if (ordered_z_p[kcount] == orig_z_p[k]) {
kcount++;
count++;
}
}
ksta = k_above_sfc-1-zap_below;
kend = ksta+kend_order-1;
kend = ksta+count-1;
} else {
// We shouldn't be in here!
amrex::Abort("metgrid initialization, !use_levels below_ground && !metgrid_use_sfc");
Expand Down

0 comments on commit b3b4c1c

Please sign in to comment.