From 2c68acfcf1914afda1c7e084cef6580ff3821392 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 4 Dec 2024 13:43:10 -0700 Subject: [PATCH 1/4] Fix conditional jump on uninitialized mem in SHOC The rino temp view only had the nlev-1 entry initialized. pblintd_height was accessing other entries. --- components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp index 34104e9a8fe5..94cb763d8d25 100644 --- a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp +++ b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp @@ -78,7 +78,7 @@ void Functions::pblintd( // Initialize bool check = true; - s_rino(nlev-1) = 0; + Kokkos::deep_copy(rino, 0); pblh = s_z(nlev-1); // PBL height calculation From 36ce06ef005ab1b7f78df904d9193a9616e428d3 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 4 Dec 2024 15:30:49 -0700 Subject: [PATCH 2/4] Remove used var --- components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp index 94cb763d8d25..ad47e450fd4f 100644 --- a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp +++ b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp @@ -67,7 +67,6 @@ void Functions::pblintd( // Scalarize views for single entry access const auto s_z = ekat::scalarize(z); const auto s_thv = ekat::scalarize(thv); - const auto s_rino = ekat::scalarize(rino); const auto s_zi = ekat::scalarize(zi); const auto s_cldn = ekat::scalarize(cldn); From 992e4fc342e77640d0ab729c8f63a723cf692fe7 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 4 Dec 2024 15:59:17 -0700 Subject: [PATCH 3/4] Fix and add comment --- .../eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp index ad47e450fd4f..cfde686ccf04 100644 --- a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp +++ b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp @@ -77,7 +77,12 @@ void Functions::pblintd( // Initialize bool check = true; - Kokkos::deep_copy(rino, 0); + // The loop below fixes valgrind uninitialized mem errs +#ifndef NDEBUG + for (size_t i=0; i Date: Wed, 4 Dec 2024 16:03:44 -0700 Subject: [PATCH 4/4] Restore old code if ndebug not on --- components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp index cfde686ccf04..4f7749463da6 100644 --- a/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp +++ b/components/eamxx/src/physics/shoc/impl/shoc_pblintd_impl.hpp @@ -67,6 +67,7 @@ void Functions::pblintd( // Scalarize views for single entry access const auto s_z = ekat::scalarize(z); const auto s_thv = ekat::scalarize(thv); + const auto s_rino = ekat::scalarize(rino); const auto s_zi = ekat::scalarize(zi); const auto s_cldn = ekat::scalarize(cldn); @@ -82,6 +83,8 @@ void Functions::pblintd( for (size_t i=0; i