Skip to content

Commit

Permalink
Correct hybrid computation for forcing UT
Browse files Browse the repository at this point in the history
  • Loading branch information
tcclevenger committed Feb 19, 2024
1 parent c768be3 commit 39c2d73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/homme/src/share/cxx/HybridVCoord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ void HybridVCoord::random_init(int seed) {

Errors::runtime_check(curr>prev,"Error! hybrid_a+hybrid_b is not increasing.\n", -1);

host_hybrid_am_real(i-1) = (host_hybrid_ai(i) + host_hybrid_ai(i))/2.0;
host_hybrid_bm_real(i-1) = (host_hybrid_bi(i) + host_hybrid_bi(i))/2.0;
host_hybrid_am_real(i-1) = (host_hybrid_ai(i) + host_hybrid_ai(i-1))/2.0;
host_hybrid_bm_real(i-1) = (host_hybrid_bi(i) + host_hybrid_bi(i-1))/2.0;
}

Kokkos::deep_copy(hybrid_ai, host_hybrid_ai);
Expand Down
13 changes: 9 additions & 4 deletions components/homme/src/theta-l_kokkos/cxx/ElementsState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,10 @@ void ElementsState::randomize(const int seed,
auto dp = m_dp3d;
auto ps = m_ps_v;
auto ps0 = hvcoord.ps0;
auto hybrid_am = hvcoord.hybrid_am;
auto hybrid_bm = hvcoord.hybrid_bm;
auto hyai = hvcoord.hybrid_ai_packed;
auto hybi = hvcoord.hybrid_bi_packed;
auto hyai_delta = hvcoord.hybrid_ai_delta;
auto hybi_delta = hvcoord.hybrid_bi_delta;
const auto tu = m_tu;
Kokkos::parallel_for(m_policy, KOKKOS_LAMBDA(const TeamMember& team) {
KernelVariables kv(team, tu);
Expand All @@ -297,10 +299,13 @@ void ElementsState::randomize(const int seed,
[&](const int idx) {
const int igp = idx / NP;
const int jgp = idx % NP;
ColumnOps::compute_midpoint_delta(kv,hyai,hyai_delta);
ColumnOps::compute_midpoint_delta(kv,hybi,hybi_delta);
team.team_barrier();
Kokkos::parallel_for(Kokkos::ThreadVectorRange(kv.team,NUM_LEV),
[&](const int ilev) {
dp(ie,tl,igp,jgp,ilev) = ps0*hybrid_am(ilev)
+ ps(ie,tl,igp,jgp)*hybrid_bm(ilev);
dp(ie,tl,igp,jgp,ilev) = ps0*hyai_delta(ilev)
+ ps(ie,tl,igp,jgp)*hybi_delta(ilev);
});
});
});
Expand Down

0 comments on commit 39c2d73

Please sign in to comment.