Skip to content

Commit

Permalink
Cleanup and GPU fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ewquon committed Aug 23, 2024
1 parent fbd1b44 commit ca05a66
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions Exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ else ()
add_subdirectory(DevTests/MetGrid)
add_subdirectory(DevTests/LandSurfaceModel)
add_subdirectory(DevTests/TemperatureSource)
add_subdirectory(DevTests/MiguelDev)
endif()
4 changes: 1 addition & 3 deletions Source/BoundaryConditions/ABLMost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ ABLMost::compute_fluxes (const int& lev,
auto q_star_arr = q_star[lev]->array(mfi);
auto t_surf_arr = t_surf[lev]->array(mfi);
auto olen_arr = olen[lev]->array(mfi);
auto pblh_arr = pblh[lev]->array(mfi);

const auto tm_arr = tm_ptr->array(mfi);
const auto tvm_arr = tvm_ptr->array(mfi);
Expand Down Expand Up @@ -570,8 +569,7 @@ ABLMost::compute_pblh (const int& lev,
moist_flag = 1;
}

est.compute_pblh(m_geom[lev],z_phys_cc,
pblh[lev].get(),u_star[lev].get(),t_star[lev].get(),
est.compute_pblh(m_geom[lev],z_phys_cc, pblh[lev].get(),
vars[lev][Vars::cons],m_lmask_lev[lev][0],
moist_flag);

Expand Down
12 changes: 8 additions & 4 deletions Source/BoundaryConditions/MOSTAverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ MOSTAverage::compute_plane_averages (int lev)
denom[iavg] = 1.0 / (Real)ncell_plane[iavg];
val_old[iavg] = plane_average[iavg]*d_fact_old;

const Real beta = m_wstar_beta;

#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
Expand Down Expand Up @@ -925,7 +927,7 @@ MOSTAverage::compute_plane_averages (int lev)
&u_interp, u_mf_arr, z_phys_arr, plo, dxInv, 1);
trilinear_interp_T(x_pos_arr(i,j,k), y_pos_arr(i,j,k), z_pos_arr(i,j,k),
&v_interp, v_mf_arr, z_phys_arr, plo, dxInv, 1);
const Real wst = (wstar_arr) ? m_wstar_beta*wstar_arr(i,j,k) : 0.0;
const Real wst = (wstar_arr) ? beta*wstar_arr(i,j,k) : 0.0;
const Real val = std::sqrt(u_interp*u_interp + v_interp*v_interp
+ wst*wst + m_Vsg[lev]*m_Vsg[lev]);
Gpu::deviceReduceSum(&plane_avg[iavg], val, handler);
Expand All @@ -942,7 +944,7 @@ MOSTAverage::compute_plane_averages (int lev)
int mi = i_arr ? i_arr(i,j,k) : i;
const Real u_val = 0.5 * (u_mf_arr(mi,mj,mk) + u_mf_arr(mi+1,mj ,mk));
const Real v_val = 0.5 * (v_mf_arr(mi,mj,mk) + v_mf_arr(mi ,mj+1,mk));
const Real wst = (wstar_arr) ? m_wstar_beta*wstar_arr(i,j,k) : 0.0;
const Real wst = (wstar_arr) ? beta*wstar_arr(i,j,k) : 0.0;
const Real val = std::sqrt(u_val*u_val + v_val*v_val
+ wst*wst + m_Vsg[lev]*m_Vsg[lev]);
Gpu::deviceReduceSum(&plane_avg[iavg], val, handler);
Expand Down Expand Up @@ -1189,6 +1191,8 @@ MOSTAverage::compute_region_averages (int lev)
int imf = 0;
int iavg = m_navg - 1;

const Real beta = m_wstar_beta;

#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
Expand Down Expand Up @@ -1226,7 +1230,7 @@ MOSTAverage::compute_region_averages (int lev)
Real zp = z_pos_arr(i+li,j+lj,k) + met_h_zeta*lk*dx[2];
trilinear_interp_T(xp, yp, zp, &u_interp, u_mf_arr, z_phys_arr, plo, dxInv, 1);
trilinear_interp_T(xp, yp, zp, &v_interp, v_mf_arr, z_phys_arr, plo, dxInv, 1);
const Real wst = (wstar_arr) ? m_wstar_beta*wstar_arr(i,j,k) : 0.0;
const Real wst = (wstar_arr) ? beta*wstar_arr(i,j,k) : 0.0;
const Real mag = std::sqrt(u_interp*u_interp + v_interp*v_interp
+ wst*wst + m_Vsg[lev]*m_Vsg[lev]);
Real val = denom * mag * d_fact_new;
Expand All @@ -1251,7 +1255,7 @@ MOSTAverage::compute_region_averages (int lev)
for (int li(mi-d_radius); li <= (mi+d_radius); ++li) {
const Real u_val = 0.5 * (u_mf_arr(li,lj,lk) + u_mf_arr(li+1,lj ,lk));
const Real v_val = 0.5 * (v_mf_arr(li,lj,lk) + v_mf_arr(li ,lj+1,lk));
const Real wst = (wstar_arr) ? m_wstar_beta*wstar_arr(i,j,k) : 0.0;
const Real wst = (wstar_arr) ? beta*wstar_arr(i,j,k) : 0.0;
const Real mag = std::sqrt(u_val*u_val + v_val*v_val
+ wst*wst + m_Vsg[lev]*m_Vsg[lev]);
Real val = denom * mag * d_fact_new;
Expand Down
4 changes: 1 addition & 3 deletions Source/BoundaryConditions/PBLHeight.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ struct MYNNPBLH {
void compute_pblh(const amrex::Geometry& geom,
const amrex::MultiFab* z_phys_cc,
amrex::MultiFab* pblh,
const amrex::MultiFab* u_star,
const amrex::MultiFab* t_star,
const amrex::MultiFab& cons,
const amrex::iMultiFab* lmask,
const int moist_flag) const
Expand Down Expand Up @@ -234,7 +232,7 @@ struct MYNNPBLH {
auto pblh_arr = pblh->array(mfi);

amrex::Box gtbx = mfi.growntilebox();
ParallelFor(gtbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
ParallelFor(gtbx, [=] AMREX_GPU_DEVICE(int i, int j, int) noexcept
{
//
// Clip PBLH_TKE to more realistic values
Expand Down

0 comments on commit ca05a66

Please sign in to comment.