One radiation call at one level.
914 BL_PROFILE(
"TwoStreamRadiation::advance()");
917 if (!
active()) {
return; }
931 "TwoStreamRadiation::advance: call_site must be pre_dycore or post_dycore");
933 "TwoStreamRadiation::advance called on a level define_level has not built");
937 m_alb_sw[lev]->boxArray().size() == cons_old.boxArray().size() &&
938 m_alb_sw[lev]->DistributionMap() == cons_old.DistributionMap(),
939 "TwoStreamRadiation: the 2D surface fields and the 3D state are laid out differently");
940 if (qheating !=
nullptr) {
942 qheating->boxArray() == cons_old.boxArray() &&
943 qheating->DistributionMap() == cons_old.DistributionMap(),
944 "TwoStreamRadiation: qheating must be the 2-component (SW, LW) field on the state's grids");
950 "TwoStreamRadiation: seb_enable is set but the SEB fields were not allocated");
958 call_site ==
"post_dycore",
959 "TwoStreamRadiation: supplying a land-surface model's forcing needs the rad_fluxes array");
962 "TwoStreamRadiation: the force-restore update needs a positive, finite dt_step");
983 const bool seb_active = rad_choice.
seb_enable;
987 const iMultiFab*
const balance_mask = seb_active ? land_mask :
nullptr;
988 if (balance_mask !=
nullptr) {
998 amrex::Print() <<
"TwoStreamRadiation: level " << lev
999 <<
" has water columns in its land mask. The force-restore "
1000 <<
"balance does not run on them; their longwave boundary is "
1001 << (t_surf !=
nullptr
1002 ?
"the surface layer's surface temperature.\n"
1003 :
"erf.rad_t_sfc (there is no surface layer at the lower boundary).\n");
1013 const bool has_external_surface_temperature =
1014 (radiation_inputs.size() > 0 && radiation_inputs[0] !=
nullptr) ||
1015 (noahmp_active && lsm_has_field(lsm, lev,
"t_sfc"));
1027 if (call_site ==
"pre_dycore") {
1028 ReduceOps<ReduceOpMin, ReduceOpMin> state_ops;
1029 ReduceData<amrex::Real, amrex::Real> state_data(state_ops);
1030 using StateTuple =
typename decltype(state_data)::Type;
1031 for (MFIter mfi(cons_old, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
1032 const auto& arr = cons_old.const_array(mfi);
1033 state_ops.eval(mfi.tilebox(), state_data,
1034 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) -> StateTuple {
1035 constexpr amrex::Real neg_inf = -std::numeric_limits<amrex::Real>::infinity();
1038 return {amrex::Math::isfinite(
rho) ?
rho : neg_inf,
1039 amrex::Math::isfinite(rth) ? rth : neg_inf};
1042 auto state_tuple = state_data.value(state_ops);
1043 amrex::Real mins[2] = {amrex::get<0>(state_tuple), amrex::get<1>(state_tuple)};
1044 ParallelDescriptor::ReduceRealMin(mins, 2);
1045 const amrex::Real rho_min = mins[0];
1046 const amrex::Real rth_min = mins[1];
1047 if (!std::isfinite(rho_min) || !std::isfinite(rth_min)) {
1048 amrex::Abort(
"TwoStreamRadiation: the state handed to the column sweep at level " +
1049 std::to_string(lev) +
", step " + std::to_string(nstep) +
1050 " has a non-finite density or rho*theta");
1052 if (!(rho_min > 0.0) || !(rth_min > 0.0)) {
1053 amrex::Abort(
"TwoStreamRadiation: the state handed to the column sweep at level " +
1054 std::to_string(lev) +
", step " + std::to_string(nstep) +
1055 " has a non-positive density (min " + std::to_string(rho_min) +
1056 ") or rho*theta (min " + std::to_string(rth_min) +
")");
1064 const bool do_sweep = (call_site !=
"post_dycore");
1073 m_diag[lev] = std::make_unique<RadiationDiagnostics>(
1089 amrex::Real SW_surface = 0.0;
1090 amrex::Real SW_TOA = 0.0;
1091 amrex::Real SW_up_TOA = 0.0;
1092 amrex::Real LW_net_surface = 0.0;
1093 amrex::Real LW_up_TOA = 0.0;
1094 amrex::Real heating_rate_max = 0.0;
1095 amrex::Real seb_residual_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
1096 amrex::Real seb_residual_max = std::numeric_limits<amrex::Real>::quiet_NaN();
1099 amrex::Real t_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
1100 amrex::Real t_s_max = std::numeric_limits<amrex::Real>::quiet_NaN();
1101 amrex::Real q_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
1102 amrex::Real q_s_max = std::numeric_limits<amrex::Real>::quiet_NaN();
1105 const MultiFab& state_cons = cons_old;
1108 if (state_cons.nComp() > 0 ) {
1116 if (do_sweep) { set_solar_state(ts_params, rad_choice,
m_orbit, epoch_time, have_datetime, lev, nstep); }
1119 amrex::Real max_heating_global = 0.0;
1120 amrex::Real sw_surface_sum = 0.0;
1121 amrex::Real sw_up_toa_sum = 0.0;
1122 amrex::Real lw_net_sum = 0.0;
1123 amrex::Real lw_up_toa_sum = 0.0;
1124 amrex::Real sw_toa_sum = 0.0;
1125 amrex::Long n_columns_total = 0;
1128 amrex::Real seb_residual_sum = 0.0;
1129 amrex::Long n_seb_columns = 0;
1139 MultiFab* qheating_mf = qheating;
1146 const bool sw_flux_from_rad = seb_active &&
1148 !(noahmp_active && lsm_has_field(lsm, lev,
"sav"));
1149 const bool lw_flux_from_rad = seb_active &&
1151 !(noahmp_active && lsm_has_field(lsm, lev,
"fira"));
1160 if ((noahmp_active && lsm_has_field(lsm, lev, lsm_broadband_albedo_name)) ||
1161 (radiation_inputs.size() > 2 && radiation_inputs[2] !=
nullptr)) {
1162 amrex::Abort(
"erf.radiation.seb_snow_enable acts on the two-stream surface "
1163 "albedo, but a land-surface model supplies the albedo here; turn "
1164 "it off with a land-surface model");
1185 if (!sw_flux_from_rad) {
1189 if (!lw_flux_from_rad) {
1203 const int surface_k = geom.Domain().smallEnd(2);
1205 lsm_field(lsm, lev,
"hfx"), sfc_sens_flux, surface_k,
1209 lsm_field(lsm, lev,
"lh"), sfc_laten_flux, surface_k,
1216 fill_or_copy_seb_field(
m_q_sfc[lev].
get(), lsm, lev,
"noahmp_water_vapor_mixing_ratio_2m_vegetated", rad_choice.
seb_q_sfc_default);
1238 const Box& rad_domain = geom.Domain();
1240 for (MFIter mfi(state_cons,
false); mfi.isValid(); ++mfi)
1242 const Box& bx = mfi.validbox();
1250 bx.smallEnd(2) == rad_domain.smallEnd(2) &&
1251 bx.bigEnd(2) == rad_domain.bigEnd(2),
1252 "TwoStream radiation requires grids that span the domain in z; "
1253 "set amr.max_grid_size_z to at least amr.n_cell in z");
1254 const auto& state_arr = state_cons.const_array(mfi);
1257 const amrex::Real dz_uniform_lev = geom.CellSize(2);
1261 Array4<const amrex::Real> z_phys_nd_arr;
1262 if (z_phys_nd !=
nullptr) {
1263 z_phys_nd_arr = z_phys_nd->const_array(mfi);
1269 Array4<amrex::Real> scratch_arr = scratch_fab.array();
1285 bool has_hetero_alb_sw =
false;
1286 Array4<const amrex::Real> hetero_alb_sw_arr;
1288 const MultiFab* lsm_albedo = noahmp_active
1289 ? lsm_field(lsm, lev, lsm_broadband_albedo_name)
1291 if (lsm_albedo !=
nullptr) {
1292 hetero_alb_sw_arr = lsm_albedo->const_array(mfi);
1293 has_hetero_alb_sw =
true;
1294 }
else if (radiation_inputs.size() > 2 && radiation_inputs[2]) {
1295 hetero_alb_sw_arr = radiation_inputs[2]->const_array(mfi);
1296 has_hetero_alb_sw =
true;
1298 hetero_alb_sw_arr =
m_alb_sw[lev]->const_array(mfi);
1299 has_hetero_alb_sw =
true;
1304 bool has_hetero_emiss_lw =
false;
1305 Array4<const amrex::Real> hetero_emiss_lw_arr;
1307 std::string varname_emiss =
"sfc_emis";
1308 int lsm_idx = noahmp_active ? lsm.
Get_DataIdx(lev, varname_emiss) : -1;
1309 if (radiation_inputs.size() > 1 && radiation_inputs[1]) {
1310 hetero_emiss_lw_arr = radiation_inputs[1]->const_array(mfi);
1311 has_hetero_emiss_lw =
true;
1312 }
else if (lsm_idx >= 0) {
1315 hetero_emiss_lw_arr = lsm_ptr->const_array(mfi);
1316 has_hetero_emiss_lw =
true;
1319 hetero_emiss_lw_arr =
m_emiss_lw[lev]->const_array(mfi);
1320 has_hetero_emiss_lw =
true;
1331 bool has_lsm_t_sfc =
false;
1332 Array4<const amrex::Real> lsm_t_sfc_arr;
1333 bool has_seb_t_sfc =
false;
1334 Array4<const amrex::Real> seb_t_sfc_arr;
1335 bool has_surface_layer =
false;
1336 Array4<const amrex::Real> surface_layer_theta_arr;
1338 std::string varname_t_sfc =
"t_sfc";
1339 int lsm_idx = noahmp_active ? lsm.
Get_DataIdx(lev, varname_t_sfc) : -1;
1340 if (radiation_inputs.size() > 0 && radiation_inputs[0]) {
1341 lsm_t_sfc_arr = radiation_inputs[0]->const_array(mfi);
1342 has_lsm_t_sfc =
true;
1343 }
else if (lsm_idx >= 0) {
1346 lsm_t_sfc_arr = lsm_ptr->const_array(mfi);
1347 has_lsm_t_sfc =
true;
1356 seb_t_sfc_arr =
m_t_sfc[lev]->const_array(mfi);
1357 has_seb_t_sfc =
true;
1359 if (t_surf !=
nullptr) {
1360 surface_layer_theta_arr = t_surf->const_array(mfi);
1361 has_surface_layer =
true;
1372 const bool has_latlon = (lat_m !=
nullptr) && (lon_m !=
nullptr);
1373 Array4<const amrex::Real> lat_arr, lon_arr;
1375 lat_arr = lat_m->const_array(mfi);
1376 lon_arr = lon_m->const_array(mfi);
1385 const bool write_fluxes = (rad_fluxes !=
nullptr);
1386 Array4<amrex::Real> rad_flux_clear_arr;
1387 FArrayBox rad_flux_cloudy_fab;
1388 Array4<amrex::Real> rad_flux_cloudy_arr;
1390 rad_flux_clear_arr = rad_fluxes->array(mfi);
1391 if (cloud_fraction > 0.0) {
1393 rad_flux_cloudy_arr = rad_flux_cloudy_fab.array();
1399 Array4<amrex::Real> sw_sfc_out;
1400 Array4<amrex::Real> lw_sfc_out;
1401 if (sw_flux_from_rad) sw_sfc_out =
m_sw_flux_sfc[lev]->array(mfi);
1402 if (lw_flux_from_rad) lw_sfc_out =
m_lw_flux_sfc[lev]->array(mfi);
1407 Array4<amrex::Real> sw_dn_out, lw_dn_out, coszen_out;
1419 const int m_canopy_top = supply_canopy ?
m_canopy_m[lev] : 0;
1421 Array4<amrex::Real> canopy_out, canopy_cosz_out, canopy_alb_out;
1422 const bool supply_canopy_alb = supply_canopy &&
m_canopy_alb[lev];
1423 if (supply_canopy_alb) { canopy_alb_out =
m_canopy_alb[lev]->array(mfi); }
1424 if (supply_canopy) {
1426 "TwoStreamRadiation: the canopy forcing of the building faces needs the rad_fluxes array");
1428 "TwoStreamRadiation: the canopy reaches above the top of the column");
1429 canopy_out =
m_canopy[lev]->array(mfi);
1438 const bool keep_beam = cover && sw_flux_from_rad &&
m_sw_beam_sfc[lev];
1439 Array4<const int> solid_arr;
1440 Array4<amrex::Real> sw_beam_out;
1441 int k_solid_top = bx.smallEnd(2) - 1;
1443 solid_arr =
m_solid[lev]->const_array(mfi);
1444 k_solid_top = amrex::min(bx.bigEnd(2), (*
m_solid[lev])[mfi].box().bigEnd(2));
1446 if (keep_beam) { sw_beam_out =
m_sw_beam_sfc[lev]->array(mfi); }
1450 Array4<amrex::Real> ground_keep_out;
1453 "TwoStreamRadiation: the walls' longwave on the ground (erf.ibseb.ground_sky_view) needs the rad_fluxes array");
1460 Array4<const int> roof_k_arr;
1461 Array4<const amrex::Real> roof_arr;
1464 "TwoStreamRadiation: the roofs of level " + std::to_string(lev) +
" are of step " +
1465 std::to_string(
m_roof_step[lev]) +
", the sweep of step " + std::to_string(nstep) +
1466 "; the immersed-boundary balance must give them before the sweep (ERF::Advance())");
1467 roof_k_arr =
m_roof_k[lev]->const_array(mfi);
1468 roof_arr =
m_roof[lev]->const_array(mfi);
1473 const auto&
lo = bx.loVect();
1474 const auto&
hi = bx.hiVect();
1475 Box xy_box(IntVect(
lo[0],
lo[1], 0), IntVect(
hi[0],
hi[1], 0));
1478 amrex::Long n_cols =
static_cast<amrex::Long
>(bx.length(0)) *
1479 static_cast<amrex::Long
>(bx.length(1));
1480 n_columns_total += n_cols;
1486 FArrayBox qheating_fallback_fab;
1487 Array4<amrex::Real> qheating_clear_arr;
1488 if (qheating_mf !=
nullptr) {
1489 qheating_clear_arr = qheating_mf->array(mfi);
1491 qheating_fallback_fab.resize(bx, 2);
1492 qheating_clear_arr = qheating_fallback_fab.array();
1497 FArrayBox qheating_cloudy_fab;
1498 Array4<amrex::Real> qheating_cloudy_arr;
1499 if (cloud_fraction > 0.0) {
1500 qheating_cloudy_fab.resize(bx, 2);
1501 qheating_cloudy_arr = qheating_cloudy_fab.array();
1505 amrex::Real max_heating_box = 0.0;
1506 amrex::Real sw_sum_box = 0.0;
1507 amrex::Real sw_up_sum_box = 0.0;
1508 amrex::Real lw_sum_box = 0.0;
1509 amrex::Real lw_up_sum_box = 0.0;
1510 amrex::Real sw_toa_sum_box = 0.0;
1514 ReduceOps<ReduceOpMax, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum> reduce_ops;
1515 ReduceData<amrex::Real, amrex::Real, amrex::Real, amrex::Real, amrex::Real, amrex::Real> reduce_data(reduce_ops);
1517 using ReduceTuple =
typename decltype(reduce_data)::Type;
1520 reduce_ops.eval(xy_box, reduce_data,
1521 [=] AMREX_GPU_DEVICE (
int i,
int j,
int ) -> ReduceTuple
1525 amrex::Real max_heating_clear = 0.0;
1526 amrex::Real sw_flux_clear = 0.0;
1527 amrex::Real sw_up_clear = 0.0;
1528 amrex::Real lw_net_clear = 0.0;
1529 amrex::Real lw_up_clear = 0.0;
1530 amrex::Real sw_toa_clear = 0.0;
1531 amrex::Real cos_zenith_col = 0.0;
1532 amrex::Real sw_beam_clear = 0.0;
1540 const bool col_on_roof = on_roofs && roof_arr(i, j, 0,
ROOF_SET) > amrex::Real(0.5)
1543 roof_col.
k_lower = roof_k_arr(i, j, 0);
1549 const TwoStreamRoof* roof_ptr = col_on_roof ? &roof_col :
nullptr;
1551 i, j, bx, dz_uniform_lev, state_arr, ts_params,
false,
1553 max_heating_clear, sw_flux_clear, sw_up_clear, lw_net_clear, lw_up_clear,
1555 z_phys_nd_arr, scratch_arr,
1556 has_hetero_alb_sw, &hetero_alb_sw_arr,
1557 has_hetero_emiss_lw, &hetero_emiss_lw_arr,
1558 has_lsm_t_sfc, &lsm_t_sfc_arr,
1559 has_seb_t_sfc && !skin_mask.
water(i, j), &seb_t_sfc_arr,
1560 has_surface_layer, &surface_layer_theta_arr,
1561 has_latlon, &lat_arr, &lon_arr,
1562 write_fluxes ? &rad_flux_clear_arr :
nullptr,
1563 &cos_zenith_col, keep_beam ? &sw_beam_clear :
nullptr, roof_ptr);
1566 if (supply_canopy) {
1569 cloud_fraction,
false, canopy_out);
1572 amrex::Real max_heating_col = max_heating_clear;
1573 amrex::Real sw_flux_col = sw_flux_clear;
1574 amrex::Real sw_up_col = sw_up_clear;
1575 amrex::Real lw_net_col = lw_net_clear;
1576 amrex::Real lw_up_col = lw_up_clear;
1577 amrex::Real sw_beam_col = sw_beam_clear;
1582 if (cloud_fraction > 0.0) {
1583 amrex::Real max_heating_cloudy = 0.0;
1584 amrex::Real sw_flux_cloudy = 0.0;
1585 amrex::Real sw_up_cloudy = 0.0;
1586 amrex::Real lw_net_cloudy = 0.0;
1587 amrex::Real lw_up_cloudy = 0.0;
1588 amrex::Real sw_toa_cloudy = 0.0;
1589 amrex::Real sw_beam_cloudy = 0.0;
1591 i, j, bx, dz_uniform_lev, state_arr, ts_params,
true,
1592 qheating_cloudy_arr,
1593 max_heating_cloudy, sw_flux_cloudy, sw_up_cloudy, lw_net_cloudy, lw_up_cloudy,
1595 z_phys_nd_arr, scratch_arr,
1596 has_hetero_alb_sw, &hetero_alb_sw_arr,
1597 has_hetero_emiss_lw, &hetero_emiss_lw_arr,
1598 has_lsm_t_sfc, &lsm_t_sfc_arr,
1599 has_seb_t_sfc && !skin_mask.
water(i, j), &seb_t_sfc_arr,
1600 has_surface_layer, &surface_layer_theta_arr,
1601 has_latlon, &lat_arr, &lon_arr,
1602 write_fluxes ? &rad_flux_cloudy_arr :
nullptr,
1603 nullptr, keep_beam ? &sw_beam_cloudy :
nullptr, roof_ptr);
1606 sw_flux_col = (1.0 - cloud_fraction) * sw_flux_clear +
1607 cloud_fraction * sw_flux_cloudy;
1608 sw_up_col = (1.0 - cloud_fraction) * sw_up_clear +
1609 cloud_fraction * sw_up_cloudy;
1610 lw_net_col = (1.0 - cloud_fraction) * lw_net_clear +
1611 cloud_fraction * lw_net_cloudy;
1612 lw_up_col = (1.0 - cloud_fraction) * lw_up_clear +
1613 cloud_fraction * lw_up_cloudy;
1614 sw_beam_col = (1.0 - cloud_fraction) * sw_beam_clear +
1615 cloud_fraction * sw_beam_cloudy;
1616 max_heating_col = std::max(max_heating_clear, max_heating_cloudy);
1617 if (supply_canopy) {
1620 cloud_fraction,
true, canopy_out);
1626 int kmin = bx.smallEnd(2);
1627 int kmax = bx.bigEnd(2);
1628 for (
int k = kmin; k <= kmax; ++k) {
1629 for (
int comp = 0; comp < 2; ++comp) {
1630 amrex::Real q_clear_val = qheating_clear_arr(i, j, k, comp);
1631 amrex::Real q_cloudy_val = qheating_cloudy_arr(i, j, k, comp);
1632 qheating_clear_arr(i, j, k, comp) =
1633 (1.0 - cloud_fraction) * q_clear_val +
1634 cloud_fraction * q_cloudy_val;
1639 for (
int k = kmin; k <= kmax + 1; ++k) {
1640 for (
int comp = 0; comp < 4; ++comp) {
1641 rad_flux_clear_arr(i, j, k, comp) =
1642 (1.0 - cloud_fraction) * rad_flux_clear_arr(i, j, k, comp) +
1643 cloud_fraction * rad_flux_cloudy_arr(i, j, k, comp);
1654 bool has_solid =
false;
1655 for (
int k = bx.smallEnd(2); k <= k_solid_top; ++k) {
1656 if (solid_arr(i, j, k) != 0) {
1657 qheating_clear_arr(i, j, k, 0) = 0.0;
1658 qheating_clear_arr(i, j, k, 1) = 0.0;
1663 amrex::Real q_max = 0.0;
1664 for (
int k = bx.smallEnd(2); k <= bx.bigEnd(2); ++k) {
1665 q_max = amrex::max(q_max, std::abs(qheating_clear_arr(i, j, k, 0)) +
1666 std::abs(qheating_clear_arr(i, j, k, 1)));
1668 max_heating_col = q_max;
1674 if (sw_flux_from_rad) sw_sfc_out(i, j, 0) = sw_flux_col;
1675 if (keep_beam) sw_beam_out(i, j, 0) = sw_beam_col;
1676 if (lw_flux_from_rad) lw_sfc_out(i, j, 0) = -lw_net_col;
1681 cos_zenith_col, sw_dn_out(i, j, 0),
1682 lw_dn_out(i, j, 0), coszen_out(i, j, 0));
1691 ground_keep_out(i, j, 0, 0) = rad_flux_clear_arr(i, j, bx.smallEnd(2), 3);
1692 ground_keep_out(i, j, 0, 1) = amrex::Real(1.0) - alb_dif_g;
1694 has_hetero_emiss_lw);
1698 if (supply_canopy) {
1699 canopy_cosz_out(i, j, 0) = (cos_zenith_col > amrex::Real(0.0)) ? cos_zenith_col : amrex::Real(0.0);
1702 if (supply_canopy_alb) {
1706 canopy_alb_out(i, j, 0, 0) = roof_col.
albedo * roof_col.
lit;
1707 canopy_alb_out(i, j, 0, 1) =
static_cast<amrex::Real
>(roof_col.
k_lower - bx.smallEnd(2));
1711 canopy_alb_out(i, j, 0, 1) = amrex::Real(0.0);
1717 return {max_heating_col, sw_flux_col, sw_up_col, lw_net_col, lw_up_col, sw_toa_clear};
1722 amrex::Gpu::synchronize();
1723 auto reduce_tuple = reduce_data.value(reduce_ops);
1724 max_heating_box = amrex::get<0>(reduce_tuple);
1725 sw_sum_box = amrex::get<1>(reduce_tuple);
1726 sw_up_sum_box = amrex::get<2>(reduce_tuple);
1727 lw_sum_box = amrex::get<3>(reduce_tuple);
1728 lw_up_sum_box = amrex::get<4>(reduce_tuple);
1729 sw_toa_sum_box = amrex::get<5>(reduce_tuple);
1732 max_heating_global = std::max(max_heating_global, max_heating_box);
1733 sw_surface_sum += sw_sum_box;
1734 sw_up_toa_sum += sw_up_sum_box;
1735 lw_net_sum += lw_sum_box;
1736 lw_up_toa_sum += lw_up_sum_box;
1737 sw_toa_sum += sw_toa_sum_box;
1745 amrex::Real sums[5] = {sw_surface_sum, sw_up_toa_sum, lw_net_sum, lw_up_toa_sum, sw_toa_sum};
1746 ParallelDescriptor::ReduceRealSum(sums, 5);
1747 sw_surface_sum = sums[0]; sw_up_toa_sum = sums[1];
1748 lw_net_sum = sums[2]; lw_up_toa_sum = sums[3];
1749 sw_toa_sum = sums[4];
1750 ParallelDescriptor::ReduceLongSum(n_columns_total);
1751 ParallelDescriptor::ReduceRealMax(max_heating_global);
1761 if (do_sweep && qheating_mf !=
nullptr &&
1762 (qheating_mf->contains_nan(0, 2, 0) || qheating_mf->contains_inf(0, 2, 0))) {
1763 amrex::Abort(
"TwoStreamRadiation: non-finite heating rate after the column sweep at level " +
1764 std::to_string(lev) +
", step " + std::to_string(nstep));
1769 static bool warned_seb_misconfig =
false;
1770 if (!warned_seb_misconfig && ParallelDescriptor::IOProcessor()) {
1771 Print() <<
"WARNING: erf.radiation.seb_diagnostic_enable=true but "
1772 "seb_enable=false; SEB residual diagnostics will report NaN. "
1773 "Set erf.radiation.seb_enable=true to enable SEB field "
1775 warned_seb_misconfig =
true;
1787 if (cover_seb && call_site ==
"post_dycore") {
1792 "TwoStreamRadiation: the ground's shadow on level " + std::to_string(lev) +
" is of step " +
1794 "; the immersed-boundary balance must give it between the sweep and the update (ERF::Advance())");
1804 "TwoStreamRadiation: what the walls send to the ground on level " + std::to_string(lev) +
" is of step " +
1806 "; the immersed-boundary balance must give it between the sweep and the update (ERF::Advance())");
1808 for (MFIter mfi(*
m_sw_flux_sfc[lev]); mfi.isValid(); ++mfi) {
1809 const Box xy_box = makeSlab(mfi.validbox(), 2, 0);
1811 const auto foot =
m_footprint[lev]->const_array(mfi);
1812 const auto shadow = take_beam ?
m_ground_shadow[lev]->const_array(mfi) : Array4<const Real>{};
1813 const auto beam = take_beam ?
m_sw_beam_sfc[lev]->const_array(mfi) : Array4<const Real>{};
1814 const auto walls = take_walls ?
m_ground_walls[lev]->const_array(mfi) : Array4<const Real>{};
1815 const auto keep = take_walls ?
m_ground_keep[lev]->const_array(mfi) : Array4<const Real>{};
1816 const auto lw = take_walls ?
m_lw_flux_sfc[lev]->array(mfi) : Array4<Real>{};
1817 ParallelFor(xy_box, [=] AMREX_GPU_DEVICE (
int i,
int j,
int) noexcept {
1818 if (foot(i, j, 0) > Real(0.5)) {
1824 sw(i, j, 0), beam(i, j, 0), walls(i, j, 0, 0), walls(i, j, 0, 1), walls(i, j, 0, 2),
1825 keep(i, j, 0, 0), keep(i, j, 0, 1), keep(i, j, 0, 2));
1826 sw(i, j, 0) +=
t.d_sw;
1827 lw(i, j, 0) +=
t.d_lw;
1829 if (take_beam && shadow(i, j, 0) > Real(0.5)) {
1830 sw(i, j, 0) -= beam(i, j, 0);
1841 seb_residual_max = 0.0;
1845 for (MFIter mfi(state_cons,
false); mfi.isValid(); ++mfi) {
1846 const Box& bx = mfi.validbox();
1847 const auto&
lo = bx.loVect();
1848 const auto&
hi = bx.hiVect();
1849 Box xy_box(IntVect(
lo[0],
lo[1], 0), IntVect(
hi[0],
hi[1], 0));
1852 Array4<const amrex::Real> sw_flux_arr =
m_sw_flux_sfc[lev]->const_array(mfi);
1853 Array4<const amrex::Real> lw_flux_arr =
m_lw_flux_sfc[lev]->const_array(mfi);
1854 Array4<const amrex::Real> hfx_arr =
m_hfx_sfc[lev]->const_array(mfi);
1855 Array4<const amrex::Real> lh_arr =
m_lh_sfc[lev]->const_array(mfi);
1856 Array4<const amrex::Real> grdflx_arr =
m_grdflx_sfc[lev]->const_array(mfi);
1858 const bool skip_footprints = cover_seb;
1859 Array4<const amrex::Real> foot_arr;
1860 if (skip_footprints) { foot_arr =
m_footprint[lev]->const_array(mfi); }
1865 amrex::Long n_cols_box = 0;
1866 amrex::Real residual_sum_box = 0.0;
1867 amrex::Real residual_max_box = 0.0;
1870 ReduceOps<ReduceOpSum, ReduceOpMax, ReduceOpSum> seb_reduce_ops;
1871 ReduceData<amrex::Real, amrex::Real, amrex::Long> seb_reduce_data(seb_reduce_ops);
1873 using SEBReduceTuple =
typename decltype(seb_reduce_data)::Type;
1875 seb_reduce_ops.eval(xy_box, seb_reduce_data,
1876 [=] AMREX_GPU_DEVICE (
int i,
int j,
int ) -> SEBReduceTuple {
1877 if ((skip_footprints && foot_arr(i, j, 0) > amrex::Real(0.5)) ||
1878 lmask.
water(i, j)) {
1879 return {amrex::Real(0.0), amrex::Real(0.0), amrex::Long(0)};
1881 amrex::Real sw_net = sw_flux_arr(i, j, 0);
1882 amrex::Real lw_net = lw_flux_arr(i, j, 0);
1883 amrex::Real hfx = hfx_arr(i, j, 0);
1884 amrex::Real lh = lh_arr(i, j, 0);
1885 amrex::Real grdflx = grdflx_arr(i, j, 0);
1891 return {residual, std::abs(residual), amrex::Long(1)};
1896 amrex::Gpu::synchronize();
1897 auto seb_reduce_tuple = seb_reduce_data.value(seb_reduce_ops);
1898 residual_sum_box = amrex::get<0>(seb_reduce_tuple);
1899 residual_max_box = amrex::get<1>(seb_reduce_tuple);
1900 n_cols_box = amrex::get<2>(seb_reduce_tuple);
1903 seb_residual_sum += residual_sum_box;
1904 seb_residual_max = std::max(seb_residual_max, residual_max_box);
1905 n_seb_columns += n_cols_box;
1907 ParallelDescriptor::ReduceRealSum(seb_residual_sum);
1908 ParallelDescriptor::ReduceRealMax(seb_residual_max);
1909 ParallelDescriptor::ReduceLongSum(n_seb_columns);
1922 const bool seb_radiation_ready =
m_flux_diag[lev].valid ||
1923 !(sw_flux_from_rad || lw_flux_from_rad);
1925 call_site ==
"post_dycore" && seb_radiation_ready) {
1926 if (!has_external_surface_temperature) {
1930 amrex::Real t_s_sum = 0.0;
1931 amrex::Real t_s_max_val = -std::numeric_limits<amrex::Real>::max();
1932 amrex::Real q_s_sum = 0.0;
1933 amrex::Real q_s_max_val = -std::numeric_limits<amrex::Real>::max();
1934 amrex::Long n_prog_columns = 0;
1940 for (MFIter mfi(state_cons,
false); mfi.isValid(); ++mfi) {
1941 const Box& bx = mfi.validbox();
1942 const auto&
lo = bx.loVect();
1943 const auto&
hi = bx.hiVect();
1944 Box xy_box(IntVect(
lo[0],
lo[1], 0), IntVect(
hi[0],
hi[1], 0));
1947 Array4<const amrex::Real> sw_flux_arr =
m_sw_flux_sfc[lev]->const_array(mfi);
1948 Array4<const amrex::Real> lw_flux_arr =
m_lw_flux_sfc[lev]->const_array(mfi);
1949 Array4<const amrex::Real> hfx_arr =
m_hfx_sfc[lev]->const_array(mfi);
1950 Array4<const amrex::Real> lh_arr =
m_lh_sfc[lev]->const_array(mfi);
1951 Array4<const amrex::Real> grdflx_arr =
m_grdflx_sfc[lev]->const_array(mfi);
1952 Array4<const amrex::Real> t_deep_arr =
m_t_deep[lev]->const_array(mfi);
1953 Array4<const amrex::Real> q_deep_arr =
m_q_deep[lev]->const_array(mfi);
1956 Array4<amrex::Real> t_s_arr =
m_t_sfc[lev]->array(mfi);
1957 Array4<amrex::Real> q_s_arr =
m_q_sfc[lev]->array(mfi);
1959 const bool hold_footprints = cover_seb;
1960 Array4<const amrex::Real> foot_arr;
1961 if (hold_footprints) { foot_arr =
m_footprint[lev]->const_array(mfi); }
1965 Array4<const amrex::Real> swe_arr;
1966 if (melt_first) { swe_arr =
m_snow.
swe(lev)->const_array(mfi); }
1970 amrex::Long n_cols_box = 0;
1971 amrex::Real t_s_sum_box = 0.0;
1972 amrex::Real t_s_max_box = -std::numeric_limits<amrex::Real>::max();
1973 amrex::Real q_s_sum_box = 0.0;
1974 amrex::Real q_s_max_box = -std::numeric_limits<amrex::Real>::max();
1977 ReduceOps<ReduceOpSum, ReduceOpMax, ReduceOpSum, ReduceOpMax, ReduceOpSum> prog_reduce_ops;
1978 ReduceData<amrex::Real, amrex::Real, amrex::Real, amrex::Real, amrex::Long> prog_reduce_data(prog_reduce_ops);
1980 using ProgReduceTuple =
typename decltype(prog_reduce_data)::Type;
1982 prog_reduce_ops.eval(xy_box, prog_reduce_data,
1991 AMREX_GPU_DEVICE (
int i,
int j,
int ) -> ProgReduceTuple {
1992 if ((hold_footprints && foot_arr(i, j, 0) > amrex::Real(0.5)) ||
1993 lmask.
water(i, j)) {
1994 constexpr amrex::Real lowest = std::numeric_limits<amrex::Real>::lowest();
1995 return {amrex::Real(0.0), lowest, amrex::Real(0.0), lowest, amrex::Long(0)};
1997 amrex::Real t_s_old = t_s_arr(i, j, 0);
1998 amrex::Real q_s_old = q_s_arr(i, j, 0);
2001 amrex::Real sw_net = sw_flux_arr(i, j, 0);
2002 amrex::Real lw_net = lw_flux_arr(i, j, 0);
2003 amrex::Real hfx = hfx_arr(i, j, 0);
2004 amrex::Real lh = lh_arr(i, j, 0);
2005 amrex::Real grdflx = grdflx_arr(i, j, 0);
2006 amrex::Real t_deep_val = t_deep_arr(i, j, 0);
2007 amrex::Real q_deep_val = q_deep_arr(i, j, 0);
2019 amrex::Real t_s_new = t_s_old + dt_step * dT_s_dt;
2020 amrex::Real q_s_new = q_s_old + dt_step * dq_s_dt;
2023 const bool under_snow = melt_first && swe_arr(i, j, 0) > amrex::Real(0.0);
2024 t_s_new = amrex::max(t_min, under_snow ? t_s_new : amrex::min(t_max, t_s_new));
2025 q_s_new = amrex::max(q_min, amrex::min(q_max, q_s_new));
2028 t_s_arr(i, j, 0) = t_s_new;
2029 q_s_arr(i, j, 0) = q_s_new;
2032 return {t_s_new, std::abs(t_s_new), q_s_new, std::abs(q_s_new), amrex::Long(1)};
2036 amrex::Gpu::synchronize();
2037 auto prog_reduce_tuple = prog_reduce_data.value(prog_reduce_ops);
2038 t_s_sum_box = amrex::get<0>(prog_reduce_tuple);
2039 t_s_max_box = amrex::get<1>(prog_reduce_tuple);
2040 q_s_sum_box = amrex::get<2>(prog_reduce_tuple);
2041 q_s_max_box = amrex::get<3>(prog_reduce_tuple);
2042 n_cols_box = amrex::get<4>(prog_reduce_tuple);
2045 t_s_sum += t_s_sum_box;
2046 t_s_max_val = std::max(t_s_max_val, t_s_max_box);
2047 q_s_sum += q_s_sum_box;
2048 q_s_max_val = std::max(q_s_max_val, q_s_max_box);
2049 n_prog_columns += n_cols_box;
2055 if (
m_t_sfc[lev]->contains_nan(0, 1, 0) ||
m_q_sfc[lev]->contains_nan(0, 1, 0)) {
2056 amrex::Abort(
"TwoStreamRadiation: non-finite surface temperature or moisture "
2057 "after the force-restore update at level " + std::to_string(lev) +
2058 ", step " + std::to_string(nstep));
2070 amrex::Real t_s_sum_snow = 0.0;
2071 amrex::Real t_s_max_snow = -std::numeric_limits<amrex::Real>::max();
2076 t_s_sum_snow, t_s_max_snow, balance_mask);
2078 t_s_sum = t_s_sum_snow;
2079 t_s_max_val = t_s_max_snow;
2082 amrex::Abort(
"TwoStreamRadiation: non-finite surface temperature, or "
2083 "non-finite or negative snow water equivalent, after the force-restore snow step at level " +
2084 std::to_string(lev) +
", step " + std::to_string(nstep));
2087 const amrex::Real inv_n = amrex::Real(1.0) /
static_cast<amrex::Real
>(ss.
columns);
2088 amrex::Print() <<
"Force-restore snow at level " << lev <<
", step " << nstep
2089 <<
" (column means, kg/m^2): snowfall = " << ss.
snowfall * inv_n
2091 <<
", melt = " << ss.
melt * inv_n
2092 <<
", snow water equivalent = " << ss.
swe * inv_n
2093 <<
"; max column budget residual = " << ss.
max_residual
2106 if (
m_q_sfc[lev]->contains_nan(0, 1, 0) ||
m_q_deep[lev]->contains_nan(0, 1, 0) ||
2107 m_t_deep[lev]->contains_nan(0, 1, 0)) {
2108 amrex::Abort(
"TwoStreamRadiation: non-finite soil water or deep temperature "
2109 "after the force-restore hydrology at level " + std::to_string(lev) +
2110 ", step " + std::to_string(nstep));
2113 const amrex::Real inv_n = amrex::Real(1.0) /
static_cast<amrex::Real
>(hs.
columns);
2114 amrex::Print() <<
"Force-restore hydrology at level " << lev <<
", step " << nstep
2115 <<
" (column means, kg/m^2 this step): rain = " << hs.
rain * inv_n
2117 <<
", runoff = " << hs.
runoff * inv_n
2118 <<
", drainage = " << hs.
drainage * inv_n
2119 <<
", deficit = " << hs.
deficit * inv_n
2120 <<
"; max column budget residual = " << hs.
max_residual
2129 amrex::Real sums[2] = {t_s_sum, q_s_sum};
2130 ParallelDescriptor::ReduceRealSum(sums, 2);
2131 t_s_sum = sums[0]; q_s_sum = sums[1];
2132 ParallelDescriptor::ReduceRealMax(t_s_max_val);
2133 ParallelDescriptor::ReduceRealMax(q_s_max_val);
2134 ParallelDescriptor::ReduceLongSum(n_prog_columns);
2138 if (n_prog_columns > 0) {
2139 t_s_mean = t_s_sum /
static_cast<amrex::Real
>(n_prog_columns);
2140 t_s_max = t_s_max_val;
2141 q_s_mean = q_s_sum /
static_cast<amrex::Real
>(n_prog_columns);
2142 q_s_max = q_s_max_val;
2144 t_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
2145 t_s_max = std::numeric_limits<amrex::Real>::quiet_NaN();
2146 q_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
2147 q_s_max = std::numeric_limits<amrex::Real>::quiet_NaN();
2153 amrex::Abort(
"erf.radiation.seb_precipitation_source and "
2154 "seb_deep_prognostic_enable act on the two-stream force-restore "
2155 "state, but a land-surface model supplies the surface temperature "
2156 "here; turn them off with a land-surface model");
2160 t_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
2161 t_s_max = std::numeric_limits<amrex::Real>::quiet_NaN();
2162 q_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
2163 q_s_max = std::numeric_limits<amrex::Real>::quiet_NaN();
2174 if (n_columns_total > 0) {
2175 const amrex::Real inv_n = 1.0 /
static_cast<amrex::Real
>(n_columns_total);
2176 SW_surface = sw_surface_sum * inv_n;
2177 SW_TOA = sw_toa_sum * inv_n;
2178 SW_up_TOA = sw_up_toa_sum * inv_n;
2179 LW_net_surface = lw_net_sum * inv_n;
2180 LW_up_TOA = lw_up_toa_sum * inv_n;
2182 heating_rate_max = max_heating_global;
2183 m_flux_diag[lev] = FluxDiag{
true, SW_surface, SW_TOA, SW_up_TOA,
2184 LW_net_surface, LW_up_TOA,
2188 if (!cached.valid) {
2199 SW_surface = cached.SW_surface;
2200 SW_TOA = cached.SW_TOA;
2201 SW_up_TOA = cached.SW_up_TOA;
2202 LW_net_surface = cached.LW_net_surface;
2203 LW_up_TOA = cached.LW_up_TOA;
2204 heating_rate_max = cached.heating_rate_max;
2209 seb_residual_mean = seb_residual_sum /
static_cast<amrex::Real
>(n_seb_columns);
2212 seb_residual_mean = std::numeric_limits<amrex::Real>::quiet_NaN();
2213 seb_residual_max = std::numeric_limits<amrex::Real>::quiet_NaN();
2219 if (rad_choice.
verbosity >= 1 && ParallelDescriptor::IOProcessor()) {
2220 Print() <<
"Radiation diagnostics at step " << nstep <<
":\n"
2221 <<
" SW TOA = " << SW_TOA <<
" W/m^2\n"
2222 <<
" SW surface = " << SW_surface <<
" W/m^2\n"
2223 <<
" SW up (TOA) = " << SW_up_TOA <<
" W/m^2\n"
2224 <<
" LW net (surface) = " << LW_net_surface <<
" W/m^2\n"
2225 <<
" LW up (TOA) = " << LW_up_TOA <<
" W/m^2\n"
2226 <<
" Max heating rate = " << heating_rate_max <<
" K/s\n";
2228 Print() <<
" SEB residual (mean) = " << seb_residual_mean <<
" W/m^2\n"
2229 <<
" SEB residual (max) = " << seb_residual_max <<
" W/m^2\n";
2232 Print() <<
" Surface temperature (mean) = " << t_s_mean <<
" K\n"
2233 <<
" Surface temperature (max) = " << t_s_max <<
" K\n"
2234 <<
" Surface moisture (mean) = " << q_s_mean <<
" m^3/m^3\n"
2235 <<
" Surface moisture (max) = " << q_s_max <<
" m^3/m^3\n";
2239 rad_diag.
append(nstep, time, call_site, SW_surface, SW_TOA,
2240 SW_up_TOA, LW_net_surface, LW_up_TOA, heating_rate_max,
2241 seb_residual_mean, seb_residual_max,
2242 t_s_mean, t_s_max, q_s_mean, q_s_max);
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
pp_for_pert_vels get("prob_type", prob_type)
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
bool rad_boxes_span_column(const amrex::BoxArray &ba, const amrex::Box &dom)
Definition: ERF_RadiationInterface.H:18
SEBLandMaskView seb_land_mask_view(const amrex::iMultiFab *mask, const amrex::MFIter &mfi)
The view of mask on the box of mfi; off when mask is nullptr.
Definition: ERF_SEBLandMask.H:54
bool seb_land_mask_has_water(const amrex::iMultiFab *mask)
True when mask holds a water column on any rank; false for nullptr.
Definition: ERF_SEBLandMask.H:70
void seb_assert_land_mask_layout(const amrex::iMultiFab *mask, const amrex::FabArrayBase &field, const char *who)
Stop when mask is given and is not on the grids of field.
Definition: ERF_SEBLandMask.H:43
SEBFluxOrigin fill_seb_turbulent_flux(MultiFab &seb_flux, SEBTurbulentFlux kind, const MultiFab *land_surface_field, const MultiFab *surface_layer_flux, int surface_k, SEBTurbulentFluxSource source, Real fallback)
Definition: ERF_SEBTurbulentFlux.cpp:64
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_seb_residual(amrex::Real sw_net, amrex::Real lw_net, amrex::Real hfx, amrex::Real lh, amrex::Real grdflx)
Diagnose the surface energy balance residual.
Definition: ERF_SimplifiedSEB.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real prognostic_dqs_dt(amrex::Real le, amrex::Real q_s, amrex::Real q_deep, amrex::Real d_s, amrex::Real tau_q)
Compute prognostic surface moisture tendency using force-restore formulation.
Definition: ERF_SimplifiedSEB.H:169
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real prognostic_dTs_dt(amrex::Real seb_residual, amrex::Real t_s, amrex::Real t_deep, amrex::Real c_s, amrex::Real tau)
Compute prognostic surface temperature tendency using force-restore formulation.
Definition: ERF_SimplifiedSEB.H:114
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void two_stream_canopy_beam(int i, int j, int kmin, int m_top, const amrex::Array4< const amrex::Real > &scratch, int f_dir_comp, bool sw_on, amrex::Real cos_zenith, amrex::Real cloud_fraction, bool blend, const amrex::Array4< amrex::Real > &beam)
Write the direct beam on a horizontal surface at the interfaces 0 .. m_top of column (i,...
Definition: ERF_TwoStreamCanopyForcing.H:94
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GroundWallTerms two_stream_ground_wall_terms(amrex::Real sw_net, amrex::Real sw_beam, amrex::Real wall_view, amrex::Real sw_walls, amrex::Real lw_walls, amrex::Real lw_down, amrex::Real absorb_dif, amrex::Real emis) noexcept
The change of the open ground's net radiation beside walls (erf.ibseb.ground_sky_view)....
Definition: ERF_TwoStreamCanopyForcing.H:233
TwoStreamParams make_two_stream_params(const RadChoice &rc, const amrex::Real rdOcp)
Copy the column-kernel parameters out of a RadChoice.
Definition: ERF_TwoStreamColumn.H:127
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw(int i, int j, const amrex::Array4< const amrex::Real > *hetero_alb_sw, const TwoStreamParams &rad_choice, bool has_hetero_alb)
Resolve per-column shortwave surface albedo from hetero field or fallback.
Definition: ERF_TwoStreamColumn.H:245
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw_diffuse(amrex::Real alb_dir, amrex::Real surface_albedo_sw_diffuse) noexcept
The ground's albedo for diffuse shortwave: the input surface_albedo_sw_diffuse, or the direct-beam al...
Definition: ERF_TwoStreamColumn.H:308
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void two_stream_land_forcing(int i, int j, int kmin, const amrex::Array4< const amrex::Real > &rad_flux, amrex::Real cos_zenith, amrex::Real &sw_dn, amrex::Real &lw_dn, amrex::Real &coszen)
The radiative forcing a land-surface model integrates on, for column (i,j).
Definition: ERF_TwoStreamColumn.H:908
amrex::Box two_stream_scratch_box(const amrex::Box &bx)
Box of the scratch FArrayBox a sweep over box bx needs.
Definition: ERF_TwoStreamColumn.H:662
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool two_stream_starts_on_roof(int k_lower, int kbot) noexcept
Whether a column starts on a roof: the layer on the roof, k_lower, is above the box's bottom layer kb...
Definition: ERF_TwoStreamColumn.H:284
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_emissivity_lw(int i, int j, const amrex::Array4< const amrex::Real > *hetero_emiss_lw, const TwoStreamParams &rad_choice, bool has_hetero_emiss)
Resolve per-column longwave surface emissivity from hetero field or fallback.
Definition: ERF_TwoStreamColumn.H:328
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void vertical_two_stream_sweep(int i, int j, const amrex::Box &bx, amrex::Real dz_uniform, const amrex::Array4< const amrex::Real > &state_arr, const TwoStreamParams &rad_choice, bool cloudy, const amrex::Array4< amrex::Real > &qheating_arr, amrex::Real &max_heating_rate, amrex::Real &sw_surface_flux, amrex::Real &sw_up_toa, amrex::Real &lw_net_surface, amrex::Real &lw_up_toa, amrex::Real &sw_down_toa, const amrex::Array4< const amrex::Real > &z_phys_nd, const amrex::Array4< amrex::Real > &scratch, bool has_hetero_alb_sw=false, const amrex::Array4< const amrex::Real > *hetero_alb_sw=nullptr, bool has_hetero_emiss_lw=false, const amrex::Array4< const amrex::Real > *hetero_emiss_lw=nullptr, bool has_lsm_t_sfc=false, const amrex::Array4< const amrex::Real > *lsm_t_sfc=nullptr, bool has_seb_t_sfc=false, const amrex::Array4< const amrex::Real > *seb_t_sfc=nullptr, bool has_surface_layer=false, const amrex::Array4< const amrex::Real > *surface_layer_theta=nullptr, bool has_latlon=false, const amrex::Array4< const amrex::Real > *lat_arr=nullptr, const amrex::Array4< const amrex::Real > *lon_arr=nullptr, const amrex::Array4< amrex::Real > *rad_flux_out=nullptr, amrex::Real *cos_zenith_out=nullptr, amrex::Real *sw_beam_absorbed_out=nullptr, const TwoStreamRoof *roof=nullptr)
GPU-safe per-column vertical integration kernel for two-stream radiation, computing either the clear-...
Definition: ERF_TwoStreamColumn.H:1004
StepSums step(int lev, const amrex::MultiFab &t_s, amrex::MultiFab &q_s, amrex::MultiFab &q_deep, amrex::MultiFab &t_deep, const amrex::MultiFab &lh, const amrex::MultiFab *footprint, amrex::Real dt, const ForceRestoreHydrologyParams &prm, const ForceRestorePrecipInput &rain, const amrex::MultiFab *snow_water=nullptr, const amrex::iMultiFab *land_mask=nullptr)
One hydrology step on every open column of lev, after the balance has updated T_s and q_s....
Definition: ERF_ForceRestoreHydrologyState.cpp:54
static ForceRestoreHydrologyParams params(const RadChoice &rc)
The parameters of one step, from the erf.radiation.seb_* inputs.
Definition: ERF_ForceRestoreHydrologyState.cpp:20
ForceRestorePrecipInput rain(int lev, amrex::Real dt) const noexcept
The rain a step of length dt takes (the total without the snow layer).
Definition: ERF_ForceRestorePrecipRate.H:87
ForceRestorePrecipInput frozen(int lev, amrex::Real dt) const noexcept
The frozen precipitation a step of length dt takes; none unless split().
Definition: ERF_ForceRestorePrecipRate.H:92
void mark_used(int lev) noexcept
The steps of this level took the rate: it is not applied again.
Definition: ERF_ForceRestorePrecipRate.cpp:113
StepSums step(int lev, amrex::MultiFab &t_s, const amrex::MultiFab &lh, const amrex::MultiFab *footprint, amrex::Real dt, const ForceRestoreSnowParams &prm, const ForceRestorePrecipInput &snowfall, amrex::Real &t_s_sum_local, amrex::Real &t_s_max_local, const amrex::iMultiFab *land_mask=nullptr)
One snow step on every open column of lev, after the balance has updated T_s. A footprint cell (footp...
Definition: ERF_ForceRestoreSnowState.cpp:54
void apply_albedo(int lev, amrex::MultiFab &alb_sw, const ForceRestoreSnowParams &prm, const amrex::MultiFab *footprint=nullptr, const amrex::iMultiFab *land_mask=nullptr) const
Write the surface albedo with snow into alb_sw, which holds the snow-free albedo: DRM95 Eq....
Definition: ERF_ForceRestoreSnowState.cpp:147
static ForceRestoreSnowParams params(const RadChoice &rc)
The parameters of one step, from the erf.radiation.seb_* inputs.
Definition: ERF_ForceRestoreSnowState.cpp:22
const amrex::MultiFab * soil_water(int lev) const noexcept
Water the last step() handed the soil [kg/m^2]: melt plus sublimation; or nullptr.
Definition: ERF_ForceRestoreSnowState.H:111
amrex::MultiFab * swe(int lev) noexcept
The snow water equivalent [kg/m^2], or nullptr.
Definition: ERF_ForceRestoreSnowState.H:101
bool defined(int lev) const noexcept
True once define_level allocated lev.
Definition: ERF_ForceRestoreSnowState.H:63
int Get_DataIdx(const int &lev, const std::string &varname)
Definition: ERF_LandSurface.H:186
amrex::MultiFab * Get_Data_Ptr(const int &lev, const int &varIdx)
Definition: ERF_LandSurface.H:142
CSV logger and debug-print manager for radiation module.
Definition: ERF_RadiationDiagnostics.H:75
void append(int step, amrex::Real time, std::string const &call_site, amrex::Real sw_surface, amrex::Real sw_toa, amrex::Real sw_up_toa, amrex::Real lw_net_surface, amrex::Real lw_up_toa, amrex::Real heating_rate_max, amrex::Real seb_residual_mean=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real seb_residual_max=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real t_s_mean=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real t_s_max=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real q_s_mean=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real q_s_max=std::numeric_limits< amrex::Real >::quiet_NaN())
Append a diagnostic row to the CSV file.
Definition: ERF_RadiationDiagnostics.cpp:79
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_footprint
Definition: ERF_TwoStreamRadiation.H:657
bool supplies_canopy_forcing(int lev) const noexcept
True when supply_canopy_forcing() was called for lev since its last define_level().
Definition: ERF_TwoStreamRadiation.H:396
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_canopy_cosz
Definition: ERF_TwoStreamRadiation.H:643
bool supplies_land_forcing(int lev) const noexcept
True when define_level allocated the land-model forcing fields on lev.
Definition: ERF_TwoStreamRadiation.H:343
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_q_sfc
Definition: ERF_TwoStreamRadiation.H:621
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_canopy_alb
Definition: ERF_TwoStreamRadiation.H:644
bool takes_ground_walls(int lev) const noexcept
True when the ground balance of lev takes what the walls send it (see set_building_cover()): the one ...
Definition: ERF_TwoStreamRadiation.H:487
ForceRestorePrecipRate m_precip
Definition: ERF_TwoStreamRadiation.H:626
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_roof
Definition: ERF_TwoStreamRadiation.H:670
bool has_building_cover(int lev) const noexcept
True when set_building_cover() was called for lev since its last define_level().
Definition: ERF_TwoStreamRadiation.H:492
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > m_roof_k
Definition: ERF_TwoStreamRadiation.H:669
amrex::Vector< int > m_roof_step
Definition: ERF_TwoStreamRadiation.H:671
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_canopy
Definition: ERF_TwoStreamRadiation.H:642
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_grdflx_sfc
Definition: ERF_TwoStreamRadiation.H:620
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_ground_walls
Definition: ERF_TwoStreamRadiation.H:664
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_lw_flux_sfc
Definition: ERF_TwoStreamRadiation.H:617
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_q_deep
Definition: ERF_TwoStreamRadiation.H:623
bool seb_q_deep_is_state() const
True when the deep water content is part of the state: it evolves (erf.radiation.seb_deep_prognostic_...
Definition: ERF_TwoStreamRadiation.H:291
amrex::Real m_rdOcp
Definition: ERF_TwoStreamRadiation.H:600
amrex::Vector< FluxDiag > m_flux_diag
Definition: ERF_TwoStreamRadiation.H:684
bool active() const
True once a level has been defined with the model selected.
Definition: ERF_TwoStreamRadiation.H:68
bool seb_t_deep_is_state() const
True when the deep temperature is part of the state: it evolves (erf.radiation.seb_deep_prognostic_en...
Definition: ERF_TwoStreamRadiation.H:268
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_ground_keep
Definition: ERF_TwoStreamRadiation.H:665
ForceRestoreHydrology m_hydro
Definition: ERF_TwoStreamRadiation.H:627
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_emiss_lw
Definition: ERF_TwoStreamRadiation.H:612
amrex::Vector< int > m_walls_step
Definition: ERF_TwoStreamRadiation.H:666
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_t_sfc
Definition: ERF_TwoStreamRadiation.H:613
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_lw_dn_sfc
Definition: ERF_TwoStreamRadiation.H:636
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_lh_sfc
Definition: ERF_TwoStreamRadiation.H:619
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_alb_sw
Definition: ERF_TwoStreamRadiation.H:611
bool starts_on_roofs(int lev) const noexcept
True when the columns of lev under a building start on its roof (erf.ibseb.two_stream_roofs; set_buil...
Definition: ERF_TwoStreamRadiation.H:454
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_sw_flux_sfc
Definition: ERF_TwoStreamRadiation.H:616
ForceRestoreSnow m_snow
Definition: ERF_TwoStreamRadiation.H:628
OrbitalCache m_orbit
Definition: ERF_TwoStreamRadiation.H:601
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_t_deep
Definition: ERF_TwoStreamRadiation.H:622
amrex::Vector< std::unique_ptr< RadiationDiagnostics > > m_diag
Definition: ERF_TwoStreamRadiation.H:608
amrex::Vector< int > m_shadow_step
Definition: ERF_TwoStreamRadiation.H:672
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_ground_shadow
Definition: ERF_TwoStreamRadiation.H:658
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_sw_dn_sfc
Definition: ERF_TwoStreamRadiation.H:635
amrex::Vector< int > m_seb_updated
Definition: ERF_TwoStreamRadiation.H:677
amrex::Vector< int > m_sweep_step
Definition: ERF_TwoStreamRadiation.H:673
amrex::Vector< int > m_shaded_step
Definition: ERF_TwoStreamRadiation.H:674
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > m_solid
Definition: ERF_TwoStreamRadiation.H:656
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_sw_beam_sfc
Definition: ERF_TwoStreamRadiation.H:659
amrex::Vector< int > m_canopy_step
Definition: ERF_TwoStreamRadiation.H:646
amrex::Vector< int > m_water_message
Definition: ERF_TwoStreamRadiation.H:682
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_hfx_sfc
Definition: ERF_TwoStreamRadiation.H:618
amrex::Vector< int > m_canopy_m
Definition: ERF_TwoStreamRadiation.H:645
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_cos_zenith
Definition: ERF_TwoStreamRadiation.H:637
@ rho
Definition: ERF_Kessler.H:25
constexpr int F_DIR
Definition: ERF_TwoStreamColumn.H:652
constexpr int NCOMP
Definition: ERF_TwoStreamColumn.H:658
@ t
Definition: ERF_WSM6.H:295
Domain sums of one step on one level (rank-reduced), for the log.
Definition: ERF_ForceRestoreHydrologyState.H:54
amrex::Real deficit
[kg/m^2]
Definition: ERF_ForceRestoreHydrologyState.H:59
amrex::Long columns
open columns updated
Definition: ERF_ForceRestoreHydrologyState.H:61
amrex::Real runoff
[kg/m^2]
Definition: ERF_ForceRestoreHydrologyState.H:57
amrex::Real evaporation
sum of E dt [kg/m^2]
Definition: ERF_ForceRestoreHydrologyState.H:56
amrex::Real rain
sum of P dt [kg/m^2]
Definition: ERF_ForceRestoreHydrologyState.H:55
amrex::Real max_residual
max |column budget residual| [kg/m^2]
Definition: ERF_ForceRestoreHydrologyState.H:60
amrex::Real drainage
[kg/m^2]
Definition: ERF_ForceRestoreHydrologyState.H:58
Domain sums of one step on one level (rank-reduced), for the log.
Definition: ERF_ForceRestoreSnowState.H:39
amrex::Real swe
sum of W_n after the step [kg/m^2]
Definition: ERF_ForceRestoreSnowState.H:43
amrex::Real sublimation
[kg/m^2]
Definition: ERF_ForceRestoreSnowState.H:41
amrex::Real snowfall
[kg/m^2]
Definition: ERF_ForceRestoreSnowState.H:40
amrex::Long columns
Definition: ERF_ForceRestoreSnowState.H:45
amrex::Long bad_columns
open columns left with a non-finite T_s, or a non-finite or negative W_n
Definition: ERF_ForceRestoreSnowState.H:47
amrex::Real melt
[kg/m^2]
Definition: ERF_ForceRestoreSnowState.H:42
amrex::Real max_residual
max |column budget residual| [kg/m^2]
Definition: ERF_ForceRestoreSnowState.H:44
What two_stream_ground_wall_terms() adds to the ground balance's net shortwave and longwave [W/m^2].
Definition: ERF_TwoStreamCanopyForcing.H:206
Container holding radiation-related choices and parameters.
Definition: ERF_RadStruct.H:142
bool seb_snow_enable
One bulk snow layer on the force-restore surface (ERF_ForceRestoreSnow.H): the snow routine of the IS...
Definition: ERF_RadStruct.H:784
bool sw_enabled
Enable shortwave (solar) radiation computation. Only used by the two-stream model.
Definition: ERF_RadStruct.H:154
std::string diag_file
Output file path for radiation diagnostics CSV. Paths are relative to the simulation working director...
Definition: ERF_RadStruct.H:278
amrex::Real surface_albedo_sw
Shortwave surface albedo fallback [0, 1] for per-column heterogeneous-surface-property resolution....
Definition: ERF_RadStruct.H:412
amrex::Real surface_emissivity_lw
Longwave surface emissivity fallback [0, 1] for per-column heterogeneous-surface-property resolution....
Definition: ERF_RadStruct.H:427
amrex::Real seb_grdflx_default
Fallback SEB ground heat flux [W/m^2]. The force-restore restoring term already represents the flux i...
Definition: ERF_RadStruct.H:610
amrex::Real diag_dedup_tol
Tolerance for time equality in duplicate guard [s]. Times within this tolerance are considered equal....
Definition: ERF_RadStruct.H:329
amrex::Real seb_restore_timescale_s
Force-restore timescale for surface temperature [s]. Relaxation time constant toward T_deep in progno...
Definition: ERF_RadStruct.H:670
std::string diag_callsite_mode
Call-site filtering mode: "both" (pre+post rows), "pre_only", or "post_only".
Definition: ERF_RadStruct.H:322
bool diag_regtest_line_enable
Enable RADIATION_DIAG: line emission. Controls regtest-parsing diagnostics line. Default true.
Definition: ERF_RadStruct.H:309
amrex::Real seb_lh_default
Fallback SEB latent heat flux [W/m^2].
Definition: ERF_RadStruct.H:603
amrex::Real seb_moisture_restore_timescale_s
Force-restore timescale for surface moisture [s]. Relaxation time constant toward q_deep in prognosti...
Definition: ERF_RadStruct.H:686
amrex::Real seb_lw_flux_default
Fallback SEB surface net longwave flux [W/m^2].
Definition: ERF_RadStruct.H:453
amrex::Real seb_q_sfc_default
Fallback SEB surface moisture, and the initial value of the prognostic one. With seb_prognostic_enabl...
Definition: ERF_RadStruct.H:618
bool diag_csv_enable
Enable CSV file append behavior. When false, no file writes; other enabled streams may still print....
Definition: ERF_RadStruct.H:316
amrex::Real seb_t_deep_default
SEB deep soil temperature [K] of every column; with seb_init_t_deep_from_file, of the water columns a...
Definition: ERF_RadStruct.H:624
amrex::Real seb_prognostic_t_max_k
Maximum clamping bound for prognostic surface temperature [K]. After each Euler update,...
Definition: ERF_RadStruct.H:703
amrex::Real rad_t_sfc
erf.rad_t_sfc: surface temperature [K] used as the longwave boundary condition wherever no land-surfa...
Definition: ERF_RadStruct.H:207
bool seb_prognostic_enable
Enable prognostic SEB surface temperature and moisture evolution. When true, integrates SEB residual ...
Definition: ERF_RadStruct.H:649
bool seb_use_radiation_fluxes
Take the SEB's net surface shortwave and longwave fluxes from the two-stream sweep itself (per column...
Definition: ERF_RadStruct.H:443
amrex::Real seb_prognostic_t_min_k
Minimum clamping bound for prognostic surface temperature [K]. After each Euler update,...
Definition: ERF_RadStruct.H:695
amrex::Real cloud_fraction
Cloud fraction in [0, 1] used to blend clear-sky and cloudy-column fluxes: F = (1 - cloud_fraction) *...
Definition: ERF_RadStruct.H:364
amrex::Real seb_prognostic_q_max
Maximum clamping bound for prognostic surface moisture [kg/kg]. After each Euler update,...
Definition: ERF_RadStruct.H:719
bool seb_hydrology_enabled() const noexcept
True when any of the force-restore hydrology inputs is on.
Definition: ERF_RadStruct.H:807
amrex::Real seb_moisture_layer_depth_m
Effective surface moisture layer depth [m]. Used in force-restore prognostic q_s equation: dq_s/dt = ...
Definition: ERF_RadStruct.H:678
SEBTurbulentFluxSource seb_turbulent_flux_source
Source of the SEB's sensible and latent heat fluxes when no land-surface model supplies them: "surfac...
Definition: ERF_RadStruct.H:460
amrex::Real seb_hfx_default
Fallback SEB sensible heat flux [W/m^2].
Definition: ERF_RadStruct.H:598
bool diag_tagged_enable
Enable tagged [RAD][...] debug lines. Controls emission of bracketed-tag debug output....
Definition: ERF_RadStruct.H:302
amrex::Real seb_q_deep_default
Deep soil moisture the prognostic q_s restores to, in q_s's units (see seb_q_sfc_default).
Definition: ERF_RadStruct.H:630
amrex::Real seb_sw_flux_default
Fallback SEB surface net shortwave flux [W/m^2].
Definition: ERF_RadStruct.H:448
bool diag_enable
Master switch for radiation diagnostics emission. When false, no diagnostics output (stdout/tagged/re...
Definition: ERF_RadStruct.H:288
amrex::Real seb_prognostic_q_min
Minimum clamping bound for prognostic surface moisture [kg/kg]. After each Euler update,...
Definition: ERF_RadStruct.H:711
bool seb_enable
Master switch for simplified SEB infrastructure. When false (default), no SEB MultiFabs are allocated...
Definition: ERF_RadStruct.H:433
bool diag_stdout_enable
Enable human-readable stdout diagnostics block. Controls tagged [RAD][...] debug line emission (when ...
Definition: ERF_RadStruct.H:295
int verbosity
Debug verbosity level (0=off, 1+=debug output). Gated debug prints only emit when this is >= 1.
Definition: ERF_RadStruct.H:272
amrex::Real seb_surface_heat_capacity
Effective surface heat capacity [J/(m^2*K)]. Used in force-restore prognostic T_s equation: dT_s/dt =...
Definition: ERF_RadStruct.H:660
bool seb_diagnostic_enable
Enable diagnostic SEB residual computation and reporting. When true, computes and reports SEB residua...
Definition: ERF_RadStruct.H:640
The land mask of one box, for a device kernel. Captured by value.
Definition: ERF_SEBLandMask.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool water(int i, int j) const noexcept
True when the balance does not run on column (i, j).
Definition: ERF_SEBLandMask.H:35
Trivially copyable subset of RadChoice used by the column kernels.
Definition: ERF_TwoStreamColumn.H:57
amrex::Real surface_albedo_sw_diffuse
Definition: ERF_TwoStreamColumn.H:74
A roof as the lower boundary of a column (erf.ibseb.two_stream_roofs): the column under a building st...
Definition: ERF_TwoStreamColumn.H:270
amrex::Real emissivity
Longwave emissivity of the roof [1].
Definition: ERF_TwoStreamColumn.H:273
amrex::Real albedo
Shortwave albedo of the roof, for the beam and for diffuse light [1].
Definition: ERF_TwoStreamColumn.H:272
amrex::Real lit
Share of the direct beam that reaches the roof: 0 where a taller building shades it [1].
Definition: ERF_TwoStreamColumn.H:275
int k_lower
First cell of the column above the roof (the roof is its lower interface)
Definition: ERF_TwoStreamColumn.H:271
amrex::Real temperature
Skin temperature of the roof [K].
Definition: ERF_TwoStreamColumn.H:274