From 39c2d732d5dfa3d3025e757569c2358a4aaca57d Mon Sep 17 00:00:00 2001 From: tcclevenger Date: Mon, 19 Feb 2024 14:07:17 -0700 Subject: [PATCH] Correct hybrid computation for forcing UT --- components/homme/src/share/cxx/HybridVCoord.cpp | 4 ++-- .../homme/src/theta-l_kokkos/cxx/ElementsState.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/components/homme/src/share/cxx/HybridVCoord.cpp b/components/homme/src/share/cxx/HybridVCoord.cpp index 569eef1d6849..199b6bc4f739 100644 --- a/components/homme/src/share/cxx/HybridVCoord.cpp +++ b/components/homme/src/share/cxx/HybridVCoord.cpp @@ -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); diff --git a/components/homme/src/theta-l_kokkos/cxx/ElementsState.cpp b/components/homme/src/theta-l_kokkos/cxx/ElementsState.cpp index 2e55c66557be..e7fe7f569c7d 100644 --- a/components/homme/src/theta-l_kokkos/cxx/ElementsState.cpp +++ b/components/homme/src/theta-l_kokkos/cxx/ElementsState.cpp @@ -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); @@ -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); }); }); });