Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions components/eamxx/src/diagnostics/longwave_cloud_forcing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ void LongwaveCloudForcingDiagnostic::compute_diagnostic_impl()
const auto& LW_flux_up = get_field_in("LW_flux_up").get_view<const Real**>();
const auto& LW_clrsky_flux_up = get_field_in("LW_clrsky_flux_up").get_view<const Real**>();

// NOTE: as part of fixing https://github.com/E3SM-Project/E3SM/issues/6803, this hack
// may have to be revised. Namely, the "radiation_ran" extra data should be removed,
// in favor of a more structured and uniform approach
const auto radiation_ran = get_field_in("LW_flux_up").get_header().get_extra_data<bool>("radiation_ran");
if (not radiation_ran) {
m_diagnostic_output.deep_copy(constants::DefaultFillValue<Real>().value);
return;
}

Kokkos::parallel_for("LongwaveCloudForcingDiagnostic",
default_policy,
KOKKOS_LAMBDA(const MemberType& team) {
Expand Down
10 changes: 0 additions & 10 deletions components/eamxx/src/diagnostics/shortwave_cloud_forcing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,11 @@ void ShortwaveCloudForcingDiagnostic::compute_diagnostic_impl()
const auto default_policy = ESU::get_default_team_policy(m_num_cols,1);

const auto& SWCF = m_diagnostic_output.get_view<Real*>();

const auto& SW_flux_dn = get_field_in("SW_flux_dn").get_view<const Real**>();
const auto& SW_flux_up = get_field_in("SW_flux_up").get_view<const Real**>();
const auto& SW_clrsky_flux_dn = get_field_in("SW_clrsky_flux_dn").get_view<const Real**>();
const auto& SW_clrsky_flux_up = get_field_in("SW_clrsky_flux_up").get_view<const Real**>();

// NOTE: as part of fixing https://github.com/E3SM-Project/E3SM/issues/6803, this hack
// may have to be revised. Namely, the "radiation_ran" extra data should be removed,
// in favor of a more structured and uniform approach
const auto radiation_ran = get_field_in("SW_flux_dn").get_header().get_extra_data<bool>("radiation_ran");
if (not radiation_ran) {
m_diagnostic_output.deep_copy(constants::DefaultFillValue<Real>().value);
return;
}

Kokkos::parallel_for("ShortwaveCloudForcingDiagnostic",
default_policy,
KOKKOS_LAMBDA(const MemberType& team) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ void run(std::mt19937_64& engine)
f.allocate_view();
const auto name = f.name();
f.get_header().get_tracking().update_time_stamp(t0);
f.get_header().set_extra_data("radiation_ran", true);
diag->set_required_field(f.get_const());
input_fields.emplace(name,f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ void run(std::mt19937_64& engine)
f.allocate_view();
const auto name = f.name();
f.get_header().get_tracking().update_time_stamp(t0);
f.get_header().set_extra_data("radiation_ran", true);
diag->set_required_field(f.get_const());
input_fields.emplace(name,f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1204,73 +1204,6 @@ void RRTMGPRadiation::run_impl (const double dt) {
});
});

// When rad does NOT run, we fill all the rad-specific output fields (i.e., NOT T_mid)
// with FillValue. We also ALWAYS set extra data to signal whether rad ran or not,
// so that diags like ShortwaveCloudForcing can decide whether it's ok to run or not
// NOTE: as part of fixing https://github.com/E3SM-Project/E3SM/issues/6803, this hack
// may have to be revised
std::vector<std::string> rad_computed_fields = {
"SW_flux_dn",
"SW_flux_up",
"SW_flux_dn_dir",
"LW_flux_up",
"LW_flux_dn",
"SW_clnclrsky_flux_dn",
"SW_clnclrsky_flux_up",
"SW_clnclrsky_flux_dn_dir",
"SW_clrsky_flux_dn",
"SW_clrsky_flux_up",
"SW_clrsky_flux_dn_dir",
"SW_clnsky_flux_dn",
"SW_clnsky_flux_up",
"SW_clnsky_flux_dn_dir",
"LW_clnclrsky_flux_up",
"LW_clnclrsky_flux_dn",
"LW_clrsky_flux_up",
"LW_clrsky_flux_dn",
"LW_clnsky_flux_up",
"LW_clnsky_flux_dn",
"cldlow",
"cldmed",
"cldhgh",
"cldtot",
"dtau067",
"dtau105",
"sunlit",
"cldfrac_rad",
"T_mid_at_cldtop",
"p_mid_at_cldtop",
"cldfrac_ice_at_cldtop",
"cldfrac_liq_at_cldtop",
"cldfrac_tot_at_cldtop",
"cdnc_at_cldtop",
"eff_radius_qc_at_cldtop",
"eff_radius_qi_at_cldtop",
"cosine_solar_zenith_angle"
};

for (auto& name : rad_computed_fields) {
auto f = get_field_out(name);
f.get_header().set_extra_data("radiation_ran",update_rad);
if (not update_rad) {
f.deep_copy(constants::DefaultFillValue<Real>().value);
}
}

// Also need to fill computed gas volume mixing ratios
for (auto& name : m_gas_names) {
// We read o3 in as a vmr already. Also, n2 and co are currently set
// as a constant value, read from file during init. Skip these.
if (name=="o3" or name == "n2" or name == "co") continue;
// The rest are computed by RRTMGP from prescribed surface values, but only when rad updates.
// Set to fillvalue here when rad does not run for consistency across restart between update steps
auto f = get_field_out(name + "_volume_mix_ratio");
f.get_header().set_extra_data("radiation_ran",update_rad);
if (not update_rad) {
f.deep_copy(constants::DefaultFillValue<Real>().value);
}
}

// If necessary, set appropriate boundary fluxes for energy and mass conservation checks.
// Any boundary fluxes not included in radiation interface are set to 0.
if (has_column_conservation_check()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ atmosphere_processes:
rrtmgp_coefficients_file_lw: ${SCREAM_DATA_DIR}/init/rrtmgp-data-lw-g128-210809.nc
rrtmgp_cloud_optics_file_sw: ${SCREAM_DATA_DIR}/init/rrtmgp-cloud-optics-coeffs-sw.nc
rrtmgp_cloud_optics_file_lw: ${SCREAM_DATA_DIR}/init/rrtmgp-cloud-optics-coeffs-lw.nc
rad_frequency: 3

grids_manager:
type: homme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
---
filename_prefix: model_output_${SUFFIX}
averaging_type: average
track_avg_cnt: true
fill_threshold: 0.25
fields:
physics_gll:
field_names:
Expand Down
24 changes: 12 additions & 12 deletions components/eamxx/tests/single-process/rrtmgp/rrtmgp_standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ TEST_CASE("rrtmgp-stand-alone", "") {
const auto& field_mgr = *ad.get_field_mgr();

// Get field managed variables we need to check
auto rad_heating_pdel = field_mgr.get_field("rad_heating_pdel", grid->name());
auto sw_flux_up = field_mgr.get_field("sw_flux_up", grid->name());

// Create deep copies so that we can check values before and after call to ad.run
// Note: we have to do some trickery here to make sure the new fields we allocate
// get the same size as the (packed) ones in the FM, otherwise the vertical dim
// might be padded in the FM fields and unpadded in our copies, which will cause
// the deep_copy below to fail.
Field rad_heating_pdel_old = Field(rad_heating_pdel.get_header().get_identifier());
const auto& ap_new = rad_heating_pdel.get_header().get_alloc_properties();
auto& ap_old = rad_heating_pdel_old.get_header().get_alloc_properties();
Field sw_flux_up_old = Field(sw_flux_up.get_header().get_identifier());
const auto& ap_new = sw_flux_up.get_header().get_alloc_properties();
auto& ap_old = sw_flux_up_old.get_header().get_alloc_properties();
ap_old.request_allocation(ap_new.get_largest_pack_size());
rad_heating_pdel_old.allocate_view();
sw_flux_up_old.allocate_view();

int rad_freq = ad_params.sublist("atmosphere_processes").sublist("rrtmgp").get<int>("rad_frequency");
// Start stepping
Expand All @@ -74,24 +74,24 @@ TEST_CASE("rrtmgp-stand-alone", "") {
auto istep = time.get_num_steps();
// Create a (deep) copy of fields we want to check before calling ad.run() so we can verify
// that these fields do or do not change as we expect them to based on the rad frequency
rad_heating_pdel_old.deep_copy(rad_heating_pdel);
sw_flux_up_old.deep_copy(sw_flux_up);

ad.run(dt);
if (atm_comm.am_i_root()) {
std::cout << " - Iteration " << std::setfill(' ') << std::setw(3) << istep << " completed";
std::cout << " [" << std::setfill(' ') << std::setw(3) << 100*(istep)/nsteps << "%]\n";
}

// Test that in between rad steps, we maintain the same value of heating rate
// get rad heating rates before; we set rad_requency to 3 in the input.yaml, so
// Test that in between rad steps, we maintain the same values of fluxes and heating rates
// get rad fluxes and heating rates before; we set rad_requency to 3 in the input.yaml, so
// the first two steps should look the same
auto d_rad_heating_pdel_new = rad_heating_pdel.get_view<Real**,Host>();
auto d_rad_heating_pdel_old = rad_heating_pdel_old.get_view<Real**,Host>();
auto d_sw_flux_up_new = sw_flux_up.get_view<Real**,Host>();
auto d_sw_flux_up_old = sw_flux_up_old.get_view<Real**,Host>();

if (istep==1 or istep%rad_freq==0) {
REQUIRE(!views_are_equal(rad_heating_pdel_old, rad_heating_pdel));
REQUIRE(!views_are_equal(sw_flux_up_old, sw_flux_up));
} else {
REQUIRE(views_are_equal(rad_heating_pdel_old, rad_heating_pdel));
REQUIRE(views_are_equal(sw_flux_up_old, sw_flux_up));
}
}

Expand Down