Skip to content

Commit 620edab

Browse files
Merge branch 'overfelt/eamxx/fix-non-determinism-in-mam' (PR #7289)
EAMxx: Fix non-determinism for mam on Chrysalis The fluxes were updated in a simple for statement, which updated the same values for every thread. Instead, use a TeamVectorRange parallel_for to update the flux entries, one entry per thread. [BFB] * overfelt/eamxx/fix-non-determinism-in-mam: Fix after rebase from master failed.
2 parents 0e4fda3 + 73beeed commit 620edab

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ void MAMMicrophysics::run_impl(const double dt) {
777777
const int month = start_of_step_ts().get_month(); // 1-based
778778
const int surface_lev = nlev - 1; // Surface level
779779
const auto &index_season_lai = index_season_lai_;
780+
const int pcnst = mam4::pcnst;
780781

781782
//NOTE: we need to initialize photo_rates_
782783
Kokkos::deep_copy(photo_rates_,0.0);
@@ -894,8 +895,9 @@ void MAMMicrophysics::run_impl(const double dt) {
894895
// These output values need to be put somewhere:
895896
Real dflx_col[gas_pcnst] = {}; // deposition velocity [1/cm/s]
896897
Real dvel_col[gas_pcnst] = {}; // deposition flux [1/cm^2/s]
897-
// Output: values are dvel, dvlx
898+
// Output: values are dvel, dflx
898899
// Input/Output: progs::stateq, progs::qqcw
900+
team.team_barrier();
899901
mam4::microphysics::perform_atmospheric_chemistry_and_microphysics(
900902
team, dt, rlats, sfc_temperature(icol), sfc_pressure(icol),
901903
wind_speed, rain, solar_flux, cnst_offline_icol, forcings_in, atm,
@@ -917,9 +919,9 @@ void MAMMicrophysics::run_impl(const double dt) {
917919
// FIXME: Possible units mismatch (dflx is in kg/cm2/s but
918920
// constituent_fluxes is kg/m2/s) (Following mimics Fortran code
919921
// behavior but we should look into it)
920-
for(int ispc = offset_aerosol; ispc < mam4::pcnst; ++ispc) {
922+
Kokkos::parallel_for(Kokkos::TeamVectorRange(team, offset_aerosol, pcnst), [&](int ispc) {
921923
constituent_fluxes(icol, ispc) -= dflx_col[ispc - offset_aerosol];
922-
}
924+
});
923925

924926
}); // parallel_for for the column loop
925927
Kokkos::fence();

0 commit comments

Comments
 (0)