Skip to content

Commit 10a423d

Browse files
committed
Merge branch 'jgfouca/eamxx_bfb_report_seed' into master (PR #7855)
Eamxx BFB baseline tests should report seed This is for compare runs. It was already being reported for generation runs. [BFB]
2 parents 9cfdf01 + bb0ca8b commit 10a423d

File tree

7 files changed

+39
-29
lines changed

7 files changed

+39
-29
lines changed

components/eamxx/src/physics/gw/impl/gw_convect_gw_sources_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ void Functions<S,D>::gw_convect_gw_sources(
4040
// Look up spectrum only if depth >= 2.5 km, else set tau0 = 0.
4141
//---------------------------------------------------------------------
4242
if ((hdepth >= hdepth_min) && (std::abs(lat) < (C::Pi/2))) {
43-
4443
//------------------------------------------------------------------
4544
// Look up the spectrum using depth and uh.
4645
//------------------------------------------------------------------
@@ -54,6 +53,8 @@ void Functions<S,D>::gw_convect_gw_sources(
5453

5554
const Int hdepth_i = static_cast<Int>(std::round(hdepth)) - 1;
5655
const Int uh_i = static_cast<Int>(std::round(uh)) + cinit.maxuh;
56+
EKAT_KERNEL_ASSERT_MSG(hdepth_i >= 0 && hdepth_i < cinit.maxh, "Bad hdepth");
57+
EKAT_KERNEL_ASSERT_MSG(uh_i >= 0 && uh_i < 2*cinit.maxuh + 1, "Bad uh");
5758
Kokkos::parallel_for(
5859
Kokkos::TeamVectorRange(team, num_pgwv), [&] (const int l) {
5960
if (Umaxi > Umini && (l >= Umini && l <= Umaxi)) {

components/eamxx/src/physics/gw/impl/gw_storm_speed_impl.hpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,25 @@ void Functions<S,D>::gw_storm_speed(
4848
});
4949

5050
// Speeds for critical level filtering.
51-
umin = init.pgwv*init.dc;
52-
umax = -init.pgwv*init.dc;
51+
if (maxi > mini) {
52+
umin = init.pgwv*init.dc;
53+
umax = -init.pgwv*init.dc;
54+
}
55+
else {
56+
using ResultType = Kokkos::MinMax<Real>::value_type;
57+
ResultType min_max_result;
5358

54-
// The type that holds both min and max results
55-
using ResultType = Kokkos::MinMax<Real>::value_type;
56-
ResultType min_max_result;
59+
Kokkos::parallel_reduce(
60+
Kokkos::TeamVectorRange(team, maxi, mini+1), [&] (const int k, ResultType& update) {
61+
if (ubm(k) < update.min_val) update.min_val = ubm(k);
62+
if (ubm(k) > update.max_val) update.max_val = ubm(k);
63+
}, Kokkos::MinMax<Real>(min_max_result));
5764

58-
Kokkos::parallel_reduce(
59-
Kokkos::TeamVectorRange(team, maxi, mini+1), [&] (const int k, ResultType& update) {
60-
if (ubm(k) < update.min_val) update.min_val = ubm(k);
61-
if (ubm(k) > update.max_val) update.max_val = ubm(k);
62-
}, Kokkos::MinMax<Real>(min_max_result));
63-
64-
team.team_barrier();
65+
team.team_barrier();
6566

66-
umin = min_max_result.min_val;
67-
umax = min_max_result.max_val;
67+
umin = min_max_result.min_val;
68+
umax = min_max_result.max_val;
69+
}
6870
}
6971

7072
} // namespace gw

components/eamxx/src/physics/gw/tests/gw_beres_src_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ struct UnitWrap::UnitTest<D>::TestGwBeresSrc : public UnitWrap::UnitTest<D>::Bas
3838
// Set up inputs
3939
GwBeresSrcData baseline_data[] = {
4040
// ncol, maxq0_conversion_factor, hdepth_scaling_factor, hdepth_min, storm_speed_min, use_gw_convect_old
41-
GwBeresSrcData(10, 0.1, 0.2, 0., 1., false, front_init_data[0]),
42-
GwBeresSrcData(11, 0.2, 0.3, 0., 2., false, front_init_data[1]),
43-
GwBeresSrcData(12, 0.3, 0.4, 0., 3., false, front_init_data[2]),
44-
GwBeresSrcData(13, 0.4, 0.5, 0., 4., false, front_init_data[3]),
41+
GwBeresSrcData(10, 0.1, 0.2, 0.5, 1., false, front_init_data[0]),
42+
GwBeresSrcData(11, 0.2, 0.3, 0.5, 2., false, front_init_data[1]),
43+
GwBeresSrcData(12, 0.3, 0.4, 0.5, 3., false, front_init_data[2]),
44+
GwBeresSrcData(13, 0.4, 0.5, 0.5, 4., false, front_init_data[3]),
4545
};
4646

4747
static constexpr Int num_runs = sizeof(baseline_data) / sizeof(GwBeresSrcData);

components/eamxx/src/physics/gw/tests/gw_convect_gw_sources_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ struct UnitWrap::UnitTest<D>::TestGwConvectGwSources : public UnitWrap::UnitTest
3838
// Set up inputs
3939
GwConvectGwSourcesData baseline_data[] = {
4040
// ncol, hdepth_min
41-
GwConvectGwSourcesData(10, 0, front_init_data[0]),
42-
GwConvectGwSourcesData(11, 0, front_init_data[1]),
43-
GwConvectGwSourcesData(12, 0, front_init_data[2]),
44-
GwConvectGwSourcesData(13, 0, front_init_data[3]),
41+
GwConvectGwSourcesData(10, 0.5, front_init_data[0]),
42+
GwConvectGwSourcesData(11, 0.5, front_init_data[1]),
43+
GwConvectGwSourcesData(12, 0.5, front_init_data[2]),
44+
GwConvectGwSourcesData(13, 0.5, front_init_data[3]),
4545
};
4646

4747
static constexpr Int num_runs = sizeof(baseline_data) / sizeof(GwConvectGwSourcesData);

components/eamxx/src/physics/gw/tests/infra/gw_unit_tests_common.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ inline auto get_common_init_data(Engine& engine)
2727
// it represents an index
2828

2929
// pver, pgwv, dc, orog_only, molec_diff, tau_0_ubc, nbot_molec, ktop, kbotbg, fcrit2, kwv
30-
GwCommonInit( 72, 20, 0.75, false, false, false, 16, 8, 66, .67, 6.28e-5),
31-
GwCommonInit( 72, 20, 0.75, true , false, true , 16, 6, 68, .67, 6.28e-5),
32-
GwCommonInit( 72, 20, 0.75, false, true , true , 16, 3, 70, .67, 6.28e-5),
33-
GwCommonInit( 72, 20, 0.75, true , true , false, 16, 0, 70, .67, 6.28e-5),
30+
GwCommonInit( 72, 20, 2.5, false, false, false, 16, 8, 66, .67, 6.28e-5),
31+
GwCommonInit( 72, 20, 2.5, true , false, true , 16, 6, 68, .67, 6.28e-5),
32+
GwCommonInit( 72, 20, 2.5, false, true , true , 16, 3, 70, .67, 6.28e-5),
33+
GwCommonInit( 72, 20, 2.5, true , true , false, 16, 0, 70, .67, 6.28e-5),
3434
};
3535

3636
for (auto& d : rv) {

components/eamxx/src/share/core/eamxx_setup_random_test.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ Engine setup_random_test(const ekat::Comm* comm=nullptr, int* return_seed=nullpt
5252
}
5353

5454
template <typename Engine=std::mt19937_64>
55-
Engine setup_random_test(const int seed)
55+
Engine setup_random_test(const int seed, const ekat::Comm* comm=nullptr)
5656
{
57+
const auto& test_name = Catch::getResultCapture().getCurrentTestName();
58+
59+
if (comm == nullptr || comm->am_i_root()) {
60+
// Print seed to screen to trace tests that fail.
61+
std::cout << " For test " << test_name << ", using stored seed: " << seed << "\n";
62+
}
63+
5764
return Engine (seed);
5865
}
5966

components/eamxx/src/share/physics/physics_test_data.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ struct UnitBase
528528
// Read the seed
529529
int seed;
530530
impl::read_scalars(m_ifile,seed);
531-
return setup_random_test(seed);
531+
return setup_random_test(seed, nullptr);
532532
}
533533
}
534534
};

0 commit comments

Comments
 (0)