@@ -259,6 +259,9 @@ void RRTMGPRadiation::set_grids(const std::shared_ptr<const GridsManager> grids_
259259 add_field<Computed>(" heat_flux" , scalar2d, W/m2, grid_name);
260260 }
261261
262+ // Working fields that we also want for diagnostic output
263+ add_field<Computed>(" cosine_solar_zenith_angle" , scalar2d, nondim, grid_name);
264+
262265 // Load bands bounds from coefficients files and compute the band centerpoint.
263266 // Store both in the grid (if not already present)
264267 const auto cm = centi*m;
@@ -324,8 +327,6 @@ void RRTMGPRadiation::init_buffers(const ATMBufferManager &buffer_manager)
324327 Real* mem = reinterpret_cast <Real*>(buffer_manager.get_memory ());
325328
326329 // 1d arrays
327- m_buffer.mu0_k = decltype (m_buffer.mu0_k )(mem, m_col_chunk_size);
328- mem += m_buffer.mu0_k .size ();
329330 m_buffer.sfc_alb_dir_vis_k = decltype (m_buffer.sfc_alb_dir_vis_k )(mem, m_col_chunk_size);
330331 mem += m_buffer.sfc_alb_dir_vis_k .size ();
331332 m_buffer.sfc_alb_dir_nir_k = decltype (m_buffer.sfc_alb_dir_nir_k )(mem, m_col_chunk_size);
@@ -342,8 +343,6 @@ void RRTMGPRadiation::init_buffers(const ATMBufferManager &buffer_manager)
342343 mem += m_buffer.sfc_flux_dif_vis_k .size ();
343344 m_buffer.sfc_flux_dif_nir_k = decltype (m_buffer.sfc_flux_dif_nir_k )(mem, m_col_chunk_size);
344345 mem += m_buffer.sfc_flux_dif_nir_k .size ();
345- m_buffer.cosine_zenith = decltype (m_buffer.cosine_zenith )(mem, m_col_chunk_size);
346- mem += m_buffer.cosine_zenith .size ();
347346
348347 // 2d arrays
349348 m_buffer.p_lay_k = decltype (m_buffer.p_lay_k )(mem, m_col_chunk_size, m_nlay);
@@ -741,6 +740,9 @@ void RRTMGPRadiation::run_impl (const double dt) {
741740 }
742741 }
743742
743+ // Get solar zenith angle device view
744+ auto d_mu0 = get_field_out (" cosine_solar_zenith_angle" ).get_view <Real*>();
745+
744746 // Loop over each chunk of columns
745747 for (int ic=0 ; ic<m_num_col_chunks; ++ic) {
746748 const int beg = m_col_chunk_beg[ic];
@@ -752,7 +754,6 @@ void RRTMGPRadiation::run_impl (const double dt) {
752754 // must be layout right
753755 ulrreal2dk d_tint = ulrreal2dk (m_buffer.d_tint .data (), m_col_chunk_size, m_nlay+1 );
754756 ulrreal2dk d_dz = ulrreal2dk (m_buffer.d_dz .data (), m_col_chunk_size, m_nlay);
755- auto d_mu0 = m_buffer.cosine_zenith ;
756757 ConvertToRrtmgpSubview conv = {beg, ncol};
757758 TIMED_INLINE_KERNEL (init_views,
758759
@@ -815,6 +816,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
815816 auto cld_tau_lw_bnd_k = conv.subview3d (m_buffer.cld_tau_lw_bnd_k );
816817 auto cld_tau_sw_gpt_k = conv.subview3d (m_buffer.cld_tau_sw_gpt_k );
817818 auto cld_tau_lw_gpt_k = conv.subview3d (m_buffer.cld_tau_lw_gpt_k );
819+ auto mu0_k = conv.subview1d (d_mu0);
818820 );
819821
820822 // Set gas concs to "view" only the first ncol columns
@@ -826,7 +828,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
826828 // Determine the cosine zenith angle
827829 // NOTE: Since we are bridging to F90 arrays this must be done on HOST and then
828830 // deep copied to a device view.
829- auto h_mu0 = Kokkos::create_mirror_view (d_mu0 );
831+ auto h_mu0 = Kokkos::create_mirror_view (mu0_k );
830832 if (m_fixed_solar_zenith_angle > 0 ) {
831833 for (int i=0 ; i<ncol; i++) {
832834 h_mu0 (i) = m_fixed_solar_zenith_angle;
@@ -839,7 +841,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
839841 h_mu0 (i) = shr_orb_cosz_c2f (calday, lat, lon, delta, m_rad_freq_in_steps * dt);
840842 }
841843 }
842- Kokkos::deep_copy (d_mu0 ,h_mu0);
844+ Kokkos::deep_copy (mu0_k ,h_mu0);
843845
844846 const auto policy = ekat::ExeSpaceUtils<ExeSpace>::get_default_team_policy (ncol, m_nlay);
845847 TIMED_KERNEL (
@@ -1026,7 +1028,7 @@ void RRTMGPRadiation::run_impl (const double dt) {
10261028 ncol, m_nlay,
10271029 p_lay_k, t_lay_k, p_lev_k, t_lev_k,
10281030 m_gas_concs_k,
1029- sfc_alb_dir_k, sfc_alb_dif_k, d_mu0 ,
1031+ sfc_alb_dir_k, sfc_alb_dif_k, mu0_k ,
10301032 lwp_k, iwp_k, rel_k, rei_k, cldfrac_tot_k,
10311033 aero_tau_sw_k, aero_ssa_sw_k, aero_g_sw_k, aero_tau_lw_k,
10321034 cld_tau_sw_bnd_k, cld_tau_lw_bnd_k,
0 commit comments