Skip to content

Commit f4fb192

Browse files
committed
Add cosine_solar_zenith_angle to Computed fields in rad
1 parent 2597f1a commit f4fb192

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

components/eamxx/src/physics/rrtmgp/eamxx_rrtmgp_process_interface.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ void RRTMGPRadiation::set_grids(const std::shared_ptr<const GridsManager> grids_
245245
add_field<Computed>("heat_flux", scalar2d, W/m2, grid_name);
246246
}
247247

248+
// Working fields that we also want for diagnostic output
249+
add_field<Computed>("cosine_solar_zenith_angle", scalar2d, nondim, grid_name);
250+
248251
// Load bands bounds from coefficients files and compute the band centerpoint.
249252
// Store both in the grid (if not already present)
250253
const auto cm = centi*m;
@@ -310,8 +313,6 @@ void RRTMGPRadiation::init_buffers(const ATMBufferManager &buffer_manager)
310313
Real* mem = reinterpret_cast<Real*>(buffer_manager.get_memory());
311314

312315
// 1d arrays
313-
m_buffer.mu0_k = decltype(m_buffer.mu0_k)(mem, m_col_chunk_size);
314-
mem += m_buffer.mu0_k.size();
315316
m_buffer.sfc_alb_dir_vis_k = decltype(m_buffer.sfc_alb_dir_vis_k)(mem, m_col_chunk_size);
316317
mem += m_buffer.sfc_alb_dir_vis_k.size();
317318
m_buffer.sfc_alb_dir_nir_k = decltype(m_buffer.sfc_alb_dir_nir_k)(mem, m_col_chunk_size);
@@ -328,8 +329,6 @@ void RRTMGPRadiation::init_buffers(const ATMBufferManager &buffer_manager)
328329
mem += m_buffer.sfc_flux_dif_vis_k.size();
329330
m_buffer.sfc_flux_dif_nir_k = decltype(m_buffer.sfc_flux_dif_nir_k)(mem, m_col_chunk_size);
330331
mem += m_buffer.sfc_flux_dif_nir_k.size();
331-
m_buffer.cosine_zenith = decltype(m_buffer.cosine_zenith)(mem, m_col_chunk_size);
332-
mem += m_buffer.cosine_zenith.size();
333332

334333
// 2d arrays
335334
m_buffer.p_lay_k = decltype(m_buffer.p_lay_k)(mem, m_col_chunk_size, m_nlay);
@@ -723,6 +722,9 @@ void RRTMGPRadiation::run_impl (const double dt) {
723722
}
724723
}
725724

725+
// Get solar zenith angle device view
726+
auto d_mu0 = get_field_out("cosine_solar_zenith_angle").get_view<Real*>();
727+
726728
// Loop over each chunk of columns
727729
for (int ic=0; ic<m_num_col_chunks; ++ic) {
728730
const int beg = m_col_chunk_beg[ic];
@@ -734,7 +736,6 @@ void RRTMGPRadiation::run_impl (const double dt) {
734736
// must be layout right
735737
ulrreal2dk d_tint = ulrreal2dk(m_buffer.d_tint.data(), m_col_chunk_size, m_nlay+1);
736738
ulrreal2dk d_dz = ulrreal2dk(m_buffer.d_dz.data(), m_col_chunk_size, m_nlay);
737-
auto d_mu0 = m_buffer.cosine_zenith;
738739
ConvertToRrtmgpSubview conv = {beg, ncol};
739740
TIMED_INLINE_KERNEL(init_views,
740741

@@ -797,6 +798,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
797798
auto cld_tau_lw_bnd_k = conv.subview3d(m_buffer.cld_tau_lw_bnd_k);
798799
auto cld_tau_sw_gpt_k = conv.subview3d(m_buffer.cld_tau_sw_gpt_k);
799800
auto cld_tau_lw_gpt_k = conv.subview3d(m_buffer.cld_tau_lw_gpt_k);
801+
auto mu0_k = conv.subview1d(d_mu0);
800802
);
801803

802804
// Set gas concs to "view" only the first ncol columns
@@ -808,7 +810,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
808810
// Determine the cosine zenith angle
809811
// NOTE: Since we are bridging to F90 arrays this must be done on HOST and then
810812
// deep copied to a device view.
811-
auto h_mu0 = Kokkos::create_mirror_view(d_mu0);
813+
auto h_mu0 = Kokkos::create_mirror_view(mu0_k);
812814
if (m_fixed_solar_zenith_angle > 0) {
813815
for (int i=0; i<ncol; i++) {
814816
h_mu0(i) = m_fixed_solar_zenith_angle;
@@ -821,7 +823,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
821823
h_mu0(i) = shr_orb_cosz_c2f(calday, lat, lon, delta, m_rad_freq_in_steps * dt);
822824
}
823825
}
824-
Kokkos::deep_copy(d_mu0,h_mu0);
826+
Kokkos::deep_copy(mu0_k,h_mu0);
825827

826828
const auto policy = ekat::ExeSpaceUtils<ExeSpace>::get_default_team_policy(ncol, m_nlay);
827829
TIMED_KERNEL(
@@ -1008,7 +1010,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
10081010
ncol, m_nlay,
10091011
p_lay_k, t_lay_k, p_lev_k, t_lev_k,
10101012
m_gas_concs_k,
1011-
sfc_alb_dir_k, sfc_alb_dif_k, d_mu0,
1013+
sfc_alb_dir_k, sfc_alb_dif_k, mu0_k,
10121014
lwp_k, iwp_k, rel_k, rei_k, cldfrac_tot_k,
10131015
aero_tau_sw_k, aero_ssa_sw_k, aero_g_sw_k, aero_tau_lw_k,
10141016
cld_tau_sw_bnd_k, cld_tau_lw_bnd_k,

components/eamxx/src/physics/rrtmgp/eamxx_rrtmgp_process_interface.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class RRTMGPRadiation : public AtmosphereProcess {
132132

133133
// Structure for storing local variables initialized using the ATMBufferManager
134134
struct Buffer {
135-
static constexpr int num_1d_ncol = 10;
135+
static constexpr int num_1d_ncol = 8;
136136
static constexpr int num_2d_nlay = 16;
137137
static constexpr int num_2d_nlay_p1 = 23;
138138
static constexpr int num_2d_nswbands = 2;
@@ -144,8 +144,6 @@ class RRTMGPRadiation : public AtmosphereProcess {
144144
static constexpr int num_3d_nlay_nlwgpts = 1;
145145

146146
// 1d size (ncol)
147-
ureal1dk cosine_zenith;
148-
ureal1dk mu0_k;
149147
ureal1dk sfc_alb_dir_vis_k;
150148
ureal1dk sfc_alb_dir_nir_k;
151149
ureal1dk sfc_alb_dif_vis_k;

0 commit comments

Comments
 (0)