ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Radiation.H
Go to the documentation of this file.
1 #ifndef ERF_RADIATION_H
2 #define ERF_RADIATION_H
3 
4 /*
5  * RTE-RRTMGP radiation model interface to ERF
6  * The original code is developed by RobertPincus, and the code is open source available at:
7  * https://github.com/earth-system-radiation/rte-rrtmgp
8  * Please reference to the following paper,
9  * https://agupubs.onlinelibrary.wiley.com/doi/amrex::Real(10.1029)/2019MS001621
10  * NOTE: we use the C++ version of RTE-RRTMGP, which is the implementation of the original Fortran
11  * code using C++ KOKKOS for CUDA, HiP and SYCL application by E3SM ECP team, the C++ version
12  * of the rte-rrtmgp code is located at:
13  * https://github.com/E3SM-Project/rte-rrtmgp
14  * The RTE-RRTMGP uses BSD-3-Clause Open Source License, if you want to make changes,
15  * and modifications to the code, please refer to BSD-3-Clause Open Source License.
16  */
17 
18 #include <ctime>
19 #include <string>
20 #include <vector>
21 #include <memory>
22 
23 #include <mo_gas_concentrations.h>
24 
25 #include <Kokkos_Core.hpp>
26 
27 #include <AMReX_ParmParse.H>
28 #include <AMReX_FArrayBox.H>
29 #include <AMReX_Geometry.H>
30 #include <AMReX_TableData.H>
31 #include <AMReX_MultiFabUtil.H>
32 #include <AMReX_PlotFileUtil.H>
33 
34 #include <ERF_RadiationInterface.H>
35 #include <ERF_RRTMGP_Interface.H>
36 #include <ERF_RRTMGP_Utils.H>
37 #include <ERF_OrbCosZenith.H>
38 #include <ERF_IndexDefines.H>
39 #include <ERF_DataStruct.H>
40 #include <ERF_EOS.H>
41 
42 #include <ERF_LandSurface.H>
43 
44 class Radiation : public IRadiation {
45 public:
46 
47  #include <ERF_Kokkos.H>
48 
49  // Constructor
50  Radiation (const int& lev,
51  SolverChoice& sc);
52 
53  // Destructor
55  {
56  // Release k-distribution data and memory pool
57  if (rrtmgp::initialized) {
59  }
60  // Note that Kokkos is now finalized in main.cpp
61  }
62 
63  virtual
64  void
65  Init (const amrex::Geometry& geom,
66  const amrex::BoxArray& ba,
67  amrex::MultiFab* cons_in) override
68  {
69  // Detect nested patches: a fine level on which some box does not span the domain
70  // vertically, so no sweep is possible and the heating is interpolated from the parent.
71  // rad_boxes_span_column is the same test ERF::rad_level_needs_interpolation applies.
72  // A level 0 that fails it is rejected when its grids are built
73  // (ERF::check_rad_level_grids), since it has no parent to interpolate from.
74  bool is_nested_patch = !rad_boxes_span_column(ba, geom.Domain());
75 
76  // Update the nested patch flag - must be set/cleared on every Init call
77  // so that levels that stop being nested after regrid will resume radiation computation
78  m_is_nested_patch = is_nested_patch;
79 
80  // Skip radiation on nested patches - heating rates will be interpolated from coarser level.
81  // Clear the column layout first, so nothing left from an earlier grid indexes this one.
82  if (is_nested_patch) {
83  m_nlay = 0;
84  m_ncol = 0;
85  m_ncol_chunk = 0;
86  m_col_offsets.clear();
87  return;
88  }
89 
90  // Reset vector of offsets for columnar data
91  m_nlay = geom.Domain().length(2);
92 
93  // Check the O3 profile here, where nlay is first known for this level,
94  // rather than at the first radiation update
95  if (m_o3vmr.size() != 1 && int(m_o3vmr.size()) != m_nlay) {
96  amrex::Abort("erf.o3vmr has " + std::to_string(m_o3vmr.size()) +
97  " values, but level " + std::to_string(m_lev) + " has " +
98  std::to_string(m_nlay) + " vertical cells: give one value, or one" +
99  " value per vertical cell of every level that runs radiation.");
100  }
101 
102  m_ncol = 0;
103  m_col_offsets.clear();
104  m_col_offsets.resize(int(ba.size()));
105  for (amrex::MFIter mfi(*cons_in); mfi.isValid(); ++mfi) {
106  const amrex::Box& vbx = mfi.validbox();
107  // Every box spans the column: a level where one does not returned above
108  AMREX_ASSERT(vbx.smallEnd(2) == geom.Domain().smallEnd(2) &&
109  vbx.bigEnd(2) == geom.Domain().bigEnd(2));
110  int nx = vbx.length(0);
111  int ny = vbx.length(1);
112  m_col_offsets[mfi.index()] = m_ncol;
113  m_ncol += nx * ny;
114  }
115 
116  // Recompute the effective chunk size from the user's request rather than
117  // clamping the stored value in place. Init() is called again for every
118  // MakeNewLevelFromScratch / MakeNewLevelFromCoarse / RemakeLevel on the same
119  // Radiation object, so an in-place clamp could only ever shrink: a rank that
120  // owned no boxes at some Init (m_ncol == 0) would pin the chunk size at zero
121  // and then spin forever in the run_impl chunk loop once a regrid handed it
122  // real boxes. Deriving from the immutable request instead lets the chunk size
123  // grow back. It is zero only when m_ncol is zero, and a rank with no columns
124  // does no radiation work.
126 
127  // NOTE: the buffers are deliberately NOT allocated here. set_grids() allocates them
128  // at the top of every Run() that actually updates radiation, and finalize_impl()
129  // frees them again at the end of it, which is what keeps only one level's worth
130  // of RRTMGP working memory resident at a time (see RRTMGP_Memory_Reduction.md).
131  // Allocating here as well would hold every level's buffers from the moment that
132  // level is created until its first Run, so the whole hierarchy would be live
133  // simultaneously at startup -- the peak the chunking exists to avoid.
134  };
135 
136  virtual
137  void
138  Run (int& level,
139  int& step,
140  double& time,
141  const double& dt,
142  const amrex::BoxArray& ba,
143  amrex::Geometry& geom,
144  amrex::MultiFab* cons_in,
145  amrex::iMultiFab* lmask,
146  amrex::MultiFab* t_surf,
147  const amrex::Vector<const amrex::MultiFab*>& lsm_input_ptrs,
148  const amrex::Vector<amrex::MultiFab*>& lsm_output_ptrs,
149  amrex::MultiFab* qheating_rates,
150  amrex::MultiFab* rad_fluxes,
151  amrex::MultiFab* z_phys,
152  amrex::MultiFab* z_sfc,
153  amrex::MultiFab* lat_ptr,
154  amrex::MultiFab* lon_ptr,
155  const bool force_update,
156  amrex::Real& declin,
157  amrex::Real& calday) override
158  {
159  // Skip radiation computation on nested patches - heating rates will be
160  // filled via interpolation from coarser level in ERF::FillPatch
161  if (m_is_nested_patch) {
162  return;
163  }
164 
166  m_nlay == geom.Domain().length(2),
167  "Radiation: m_nlay (" + std::to_string(m_nlay) +
168  ") doesn't match domain vertical extent (" +
169  std::to_string(geom.Domain().length(2)) + ")");
170 
171  set_grids(level, step, time, dt, ba, geom,
172  cons_in, lmask, t_surf,
173  lsm_input_ptrs, qheating_rates,
174  rad_fluxes, z_phys, z_sfc, lat_ptr, lon_ptr,
175  force_update);
176  rad_run_impl(lsm_output_ptrs);
177  declin = m_declin;
178  calday = m_calday;
179  }
180 
181  bool radiation_updated () const override { return m_update_rad && !m_is_nested_patch; }
182 
183  // Set the grid info for columnar data in KOKKOS
184  void
185  set_grids (int& level,
186  int& step,
187  double& time,
188  const double& dt,
189  const amrex::BoxArray& ba,
190  amrex::Geometry& geom,
191  amrex::MultiFab* cons_in,
192  amrex::iMultiFab* lmask,
193  amrex::MultiFab* t_surf,
194  const amrex::Vector<const amrex::MultiFab*>& lsm_input_ptrs,
195  amrex::MultiFab* qheating_rates,
196  amrex::MultiFab* rad_fluxes,
197  amrex::MultiFab* z_phys,
198  amrex::MultiFab* z_sfc,
199  amrex::MultiFab* lat,
200  amrex::MultiFab* lon,
201  const bool force_update);
202 
203  // Initialize the temporary variables
204  void
205  alloc_buffers ();
206 
207  // Clear the temporary variables
208  void
209  dealloc_buffers ();
210 
211  // Fill KOKKOS Views from AMReX MultiFabs
212  void
213  mf_to_kokkos_buffers (amrex::iMultiFab* lmask,
214  amrex::MultiFab* t_surf,
215  const amrex::Vector<const amrex::MultiFab*>& lsm_input_ptrs);
216 
217  // Fill AMReX MultiFabs from KOKKOS Views
218  void
219  kokkos_buffers_to_mf (const amrex::Vector<amrex::MultiFab*>& lsm_output_ptrs);
220 
221  // Write the rrtmgp fluxes
222  void
224 
225  // Initialize the implementation
226  void
227  initialize_impl ();
228 
229  // Run the implementation
230  void
231  run_impl ();
232 
233  // Finalize the implementation
234  void
235  finalize_impl (const amrex::Vector<amrex::MultiFab*>& lsm_output_ptrs);
236 
237  // Wrapper for implementation steps
238  void
239  rad_run_impl (const amrex::Vector<amrex::MultiFab*>& lsm_output_ptrs)
240  {
241  if (m_update_rad) {
242  amrex::Print() << "Radiation advancing level " << m_lev << " at (YY-MM-DD SS) " << m_orbital_year << '-'
243  << m_orbital_mon << '-' << m_orbital_day << ' ' << m_orbital_sec << " ...";
244  this->initialize_impl();
245  this->run_impl();
246  this->finalize_impl(lsm_output_ptrs);
247  amrex::Print() << "DONE\n";
248  }
249  }
250 
251  // Get names input varnames for lsm
252  virtual
253  amrex::Vector<std::string>
255  {
256  return m_lsm_input_names;
257  }
258 
259  // Get names output varnames for lsm
260  virtual
261  amrex::Vector<std::string>
263  {
264  return m_lsm_output_names;
265  }
266 
267  // Populate datalog structures
268  void
270 
271  // Write datalog
272  virtual
273  void
274  WriteDataLog (const double &time) override;
275 
276 private:
277 
278  // Process interface vars from ERF/AMReX
279  //===================================================================================
280 
281  // True if this level is a nested patch that doesn't reach model top
282  bool m_is_nested_patch = false;
283 
284  // Grid level
285  int m_lev = -1;
286 
287  // Step number
288  int m_step;
289 
290  // Current time
291  double m_time;
292 
293  // Timestep at given level
294  double m_dt;
295 
296  // Geometry at given level
297  amrex::Geometry m_geom;
298 
299  // BoxArray at given level
300  amrex::BoxArray m_ba;
301 
302  // Are we updating radiation?
303  bool m_update_rad = false;
304 
305  // Are we writing out the fluxes?
306  bool m_rad_write_fluxes = false;
307 
308  // Do we have moisture and cold comps?
309  bool m_moist = false;
310  bool m_ice = false;
311  int m_qi_comp = -1;
312 
313  // Do we have a land surface model?
314  bool m_lsm = false;
315 
316  // List of input parameter names
317  amrex::Vector<std::string> m_lsm_input_names = {"t_sfc" , "sfc_emis" ,
318  "sfc_alb_dir_vis", "sfc_alb_dir_nir",
319  "sfc_alb_dif_vis", "sfc_alb_dif_nir"};
320 
321  // List of output parameter names
322  amrex::Vector<std::string> m_lsm_output_names = {"cos_zenith_angle" , "sw_flux_dn" ,
323  "sw_flux_dn_dir_vis", "sw_flux_dn_dir_nir",
324  "sw_flux_dn_dif_vis", "sw_flux_dn_dif_nir",
325  "lw_flux_dn"};
326 
327  // T surf if no LSM is available
328  amrex::Real m_rad_t_sfc = -1;
329  amrex::Real m_rdOcp = RdoCp;
330 
331  // Pointer to the CC conserved vars
332  amrex::MultiFab* m_cons_in = nullptr;
333 
334  // Pointer to the radiation source terms
335  amrex::MultiFab* m_qheating_rates = nullptr;
336 
337  // Pointer to the radiation fluxes
338  amrex::MultiFab* m_rad_fluxes = nullptr;
339 
340  // Pointer to the terrain heights
341  amrex::MultiFab* m_z_phys = nullptr;
342 
343  // Pointer to the heights of the ground at the nodes, given with m_z_phys
344  amrex::MultiFab* m_z_sfc = nullptr;
345 
346  // Pointer to latitude and longitude
347  amrex::MultiFab* m_lat = nullptr;
348  amrex::MultiFab* m_lon = nullptr;
349 
350  // Constant lat/lon if the above MFs are not valid
351  amrex::Real m_lat_cons;
352  amrex::Real m_lon_cons;
353 
354  // Holds output from KOKKOS views used in the datalog: cell-centered profiles, and the
355  // fluxes on the surface and top-of-atmosphere faces (one cell thick in z)
356  amrex::MultiFab datalog_mf;
357  amrex::MultiFab datalog_bdy_mf;
358 
359  // Datalog layout. Fluxes come in sets of sw up, sw dn, sw dn dir, lw up and lw dn: the
360  // all-sky and clear-sky sets are always written, the clean-sky and clean-clear-sky sets
361  // only when enabled. Every count below derives from these, so nDatalogFluxComp() can
362  // never exceed max_datalog_flux, which sizes the per-cell flux arrays in populateDatalogMF.
363  static constexpr int n_flux_per_set = 5;
364  static constexpr int n_flux_sets_base = 2;
365  static constexpr int n_flux_sets_optional = 2;
367 
368  // Cell-centered components that are not fluxes: height, heating rates (4) and mu0
369  static constexpr int n_datalog_nonflux = 6;
370 
371  // Number of flux fields in the datalog for the enabled diagnostics
372  int nDatalogFluxComp () const
373  {
374  const int n_opt = (m_extra_clnsky_diag ? 1 : 0) + (m_extra_clnclrsky_diag ? 1 : 0);
375  return n_flux_per_set * (n_flux_sets_base + n_opt);
376  }
377 
378  // Cell-centered datalog components: the non-flux fields and the fluxes
379  int nDatalogComp () const { return n_datalog_nonflux + nDatalogFluxComp(); }
380 
381  // Layout of datalog_bdy_mf: fluxes on the surface face, fluxes on the top face, then the
382  // top-face height. Usable in device code.
383  AMREX_GPU_HOST_DEVICE static constexpr int bdySfcComp (int n) { return n; }
384  AMREX_GPU_HOST_DEVICE static constexpr int bdyToaComp (int n, int nflux) { return nflux + n; }
385  AMREX_GPU_HOST_DEVICE static constexpr int bdyZtopComp (int nflux) { return 2*nflux; }
386 
387  int nDatalogBdyComp () const { return bdyZtopComp(nDatalogFluxComp()) + 1; }
388 
389  // Path, data file, and coefficient file for K-distribution
390  std::string rrtmgp_file_path = ".";
391  std::string rrtmgp_coeffs_sw = "rrtmgp-data-sw-g224-2018-12-04.nc";
392  std::string rrtmgp_coeffs_lw = "rrtmgp-data-lw-g256-2018-12-04.nc";
393  std::string rrtmgp_cloud_optics_sw = "rrtmgp-cloud-optics-coeffs-sw.nc";
394  std::string rrtmgp_cloud_optics_lw = "rrtmgp-cloud-optics-coeffs-lw.nc";
399 
400  // Active gases
401  int m_ngas = 8;
402  const std::vector<std::string> m_gas_names = {"H2O", "CO2", "O3", "N2O",
403  "CO" , "CH4", "O2", "N2" };
404  const std::vector<amrex::Real> m_mol_weight_gas = {amrex::Real(18.01528), amrex::Real(44.00950), amrex::Real(47.9982), amrex::Real(44.0128),
405  amrex::Real(28.01010), amrex::Real(16.04246), amrex::Real(31.9980), amrex::Real(28.0134)}; // g/mol
406 
407  // Prescribed greenhouse gas surface concentrations in moles / moles air
408  amrex::Real m_co2vmr = amrex::Real(388.717e-6);
409  // One value applies to the whole column; otherwise one value per layer (nlay)
410  amrex::Vector<amrex::Real> m_o3vmr{amrex::Real(3.0e-8)};
411  amrex::Real m_n2ovmr = amrex::Real(323.141e-9);
412  amrex::Real m_covmr = amrex::Real(1.0e-7);
413  amrex::Real m_ch4vmr = amrex::Real(1807.851e-9);
414  amrex::Real m_o2vmr = amrex::Real(0.209448);
415  amrex::Real m_n2vmr = amrex::Real(0.7906);
416  //amrex::Real m_f11vmr = amrex::Real(768.7644e-12);
417  //amrex::Real m_f12vmr = amrex::Real(531.2820e-12);
418 
421  std::vector<std::string> gas_names_offset;
422 
423  GasConcsK<amrex::Real, layout_t, KokkosDefaultDevice> m_gas_concs;
424 
425  // Process interface vars modeled after EAMXX
426  //===================================================================================
427 
428  // Keep track of number of columns and levels
429  int m_ncol;
430  int m_nlay;
431 
432  // Offsets for MultiFab <-> KOKKOS transfer
433  amrex::Vector<int> m_col_offsets;
434 
435  // Whether we use aerosol forcing in radiation.
436  // Aerosol plumbing is currently not implemented; this hook is retained so a
437  // future aerosol scheme can wire in without reintroducing the parameter.
438  // Setting it true today triggers an abort in the Radiation constructor.
439  bool m_do_aerosol_rad = false;
440 
441  // Whether we do extra aerosol forcing calls
442  bool m_extra_clnsky_diag = false;
444 
445  // The orbital year, used for zenith angle calculations:
446  // If >= 0, use constant orbital year for duration of simulation
447  // If < 0, use year from timestamp for orbital parameters
448  int m_orbital_year = -9999;
449  int m_orbital_mon = -9999;
450  int m_orbital_day = -9999;
451  int m_orbital_sec = -9999;
452 
453  // Orbital parameters, used for zenith angle calculations. Each is honored
454  // independently of the others:
455  // If >= 0, bypass computation based on orbital year and use the given value
456  // If < 0, compute based on orbital year, specified above
457  bool m_fixed_orbital_year = false;
458  amrex::Real m_orbital_eccen = -amrex::Real(9999.); // Eccentricity
459  amrex::Real m_orbital_obliq = -amrex::Real(9999.); // Obliquity
460  amrex::Real m_orbital_mvelp = -amrex::Real(9999.); // Vernal Equinox Mean Longitude of Perihelion
461 
462  // Value for prescribing an invariant solar constant (i.e. total solar irradiance
463  // at TOA). Used for idealized experiments such as RCE. This is only used when a
464  // positive value is supplied.
465  amrex::Real m_fixed_total_solar_irradiance = -amrex::Real(9999.);
466 
467  // Fixed solar zenith angle to use for shortwave calculations
468  // This is only used if a positive value is supplied
470 
471  amrex::Real m_declin = 0.0;
472  amrex::Real m_calday = 0.0;
473 
474  // Dimensions to be read from lookup data
479 
480  // Rad frequency in number of steps
482 
483  // Number of columns to process per RRTMGP chunk (controls peak memory).
484  // m_ncol_chunk_requested is the user's erf.rad_ncol_chunk; it is set once in the
485  // constructor and never modified thereafter, so it is a valid upper bound on the
486  // chunk size for every level and every regrid. m_ncol_chunk is the effective chunk
487  // size for the current grids and is recomputed from the request in each Init();
488  // it is zero exactly when this rank owns no columns.
490  int m_ncol_chunk = 1024;
491 
492  // Number of vars for s_mem allocation
493  int m_rad_nvar = 12;
494 
495  // Whether or not to do subcolumn sampling of cloud state for MCICA
496  bool m_do_subcol_sampling = true;
497 
498  // 1d size (1 or nlay)
500 
501  // 1d size (ncol)
516 
517  // 2d size (ncol, nlay)
534 
535  // 2d size (ncol, nlay+1)
559 
560  // 3d size (ncol, nlay+1, nswbands)
565 
566  // 3d size (ncol, nlay+1, nlwbands)
569 
570  // 2d size (ncol, nswbands)
573 
574  // Aerosol optical properties. Dormant scaffolding kept so a future aerosol
575  // coupling (e.g. SPA, prescribed aerosol climatology) can populate these
576  // without re-adding members. Only allocated when m_do_aerosol_rad is true,
577  // which currently aborts in the constructor; when aerosol coupling is
578  // wired in, remove the abort and pass these into rrtmgp_main.
579  //
580  // 3d size (ncol, nlay, n[sw,lw]bands)
585 };
586 #endif
constexpr amrex::Real RdoCp
Definition: ERF_Constants.H:57
const int nx
Definition: ERF_InitCustomPertVels_CloudChamber.H:14
const int ny
Definition: ERF_InitCustomPertVels_CloudChamber.H:15
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
Kokkos::View< RealT *, KokkosDefaultDevice > real1d_k
Definition: ERF_Kokkos.H:18
Kokkos::View< RealT ***, layout_t, KokkosDefaultDevice > real3d_k
Definition: ERF_Kokkos.H:20
Kokkos::View< RealT **, layout_t, KokkosDefaultDevice > real2d_k
Definition: ERF_Kokkos.H:19
bool rad_boxes_span_column(const amrex::BoxArray &ba, const amrex::Box &dom)
Definition: ERF_RadiationInterface.H:18
Definition: ERF_RadiationInterface.H:30
Definition: ERF_Radiation.H:44
real3d_k sw_bnd_flux_dn
Definition: ERF_Radiation.H:562
amrex::MultiFab * m_lon
Definition: ERF_Radiation.H:348
real2d_k lw_flux_up
Definition: ERF_Radiation.H:542
virtual amrex::Vector< std::string > get_lsm_output_varnames() override
Definition: ERF_Radiation.H:262
real3d_k aero_tau_sw
Definition: ERF_Radiation.H:581
int m_o3_size
Definition: ERF_Radiation.H:419
real3d_k sw_bnd_flux_dir
Definition: ERF_Radiation.H:563
real2d_k sw_clnsky_flux_dn
Definition: ERF_Radiation.H:551
std::string rrtmgp_coeffs_file_sw
Definition: ERF_Radiation.H:395
std::string rrtmgp_coeffs_sw
Definition: ERF_Radiation.H:391
real2d_k d_tint
Definition: ERF_Radiation.H:536
real2d_k lw_clnclrsky_flux_dn
Definition: ERF_Radiation.H:554
int m_rad_freq_in_steps
Definition: ERF_Radiation.H:481
void mf_to_kokkos_buffers(amrex::iMultiFab *lmask, amrex::MultiFab *t_surf, const amrex::Vector< const amrex::MultiFab * > &lsm_input_ptrs)
Definition: ERF_Radiation.cpp:589
real2d_k lwp
Definition: ERF_Radiation.H:528
void set_grids(int &level, int &step, double &time, const double &dt, const amrex::BoxArray &ba, amrex::Geometry &geom, amrex::MultiFab *cons_in, amrex::iMultiFab *lmask, amrex::MultiFab *t_surf, const amrex::Vector< const amrex::MultiFab * > &lsm_input_ptrs, amrex::MultiFab *qheating_rates, amrex::MultiFab *rad_fluxes, amrex::MultiFab *z_phys, amrex::MultiFab *z_sfc, amrex::MultiFab *lat, amrex::MultiFab *lon, const bool force_update)
Definition: ERF_Radiation.cpp:257
real1d_k lw_src
Definition: ERF_Radiation.H:515
real2d_k eff_radius_qi
Definition: ERF_Radiation.H:527
void dealloc_buffers()
Definition: ERF_Radiation.cpp:499
real1d_k m_gas_mol_weights
Definition: ERF_Radiation.H:420
amrex::Real m_lon_cons
Definition: ERF_Radiation.H:352
int nDatalogComp() const
Definition: ERF_Radiation.H:379
void initialize_impl()
Definition: ERF_Radiation.cpp:1292
int m_nswbands
Definition: ERF_Radiation.H:475
bool m_do_aerosol_rad
Definition: ERF_Radiation.H:439
std::string rrtmgp_coeffs_lw
Definition: ERF_Radiation.H:392
void rad_run_impl(const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
Definition: ERF_Radiation.H:239
bool m_moist
Definition: ERF_Radiation.H:309
std::string rrtmgp_cloud_optics_file_lw
Definition: ERF_Radiation.H:398
amrex::MultiFab * m_cons_in
Definition: ERF_Radiation.H:332
amrex::MultiFab datalog_mf
Definition: ERF_Radiation.H:356
static constexpr int n_flux_sets_base
Definition: ERF_Radiation.H:364
Radiation(const int &lev, SolverChoice &sc)
Definition: ERF_Radiation.cpp:86
int nDatalogBdyComp() const
Definition: ERF_Radiation.H:387
int m_ncol_chunk_requested
Definition: ERF_Radiation.H:489
real2d_k sw_heating
Definition: ERF_Radiation.H:530
bool m_lsm
Definition: ERF_Radiation.H:314
bool m_do_subcol_sampling
Definition: ERF_Radiation.H:496
real3d_k lw_bnd_flux_dn
Definition: ERF_Radiation.H:568
bool m_rad_write_fluxes
Definition: ERF_Radiation.H:306
real3d_k sw_bnd_flux_up
Definition: ERF_Radiation.H:561
int nDatalogFluxComp() const
Definition: ERF_Radiation.H:372
real2d_k qv_lay
Definition: ERF_Radiation.H:522
int m_qi_comp
Definition: ERF_Radiation.H:311
std::string rrtmgp_cloud_optics_file_sw
Definition: ERF_Radiation.H:397
amrex::Vector< std::string > m_lsm_output_names
Definition: ERF_Radiation.H:322
bool m_is_nested_patch
Definition: ERF_Radiation.H:282
void run_impl()
Definition: ERF_Radiation.cpp:1317
real2d_k sw_clnclrsky_flux_dn_dir
Definition: ERF_Radiation.H:546
real1d_k sfc_flux_dif_vis
Definition: ERF_Radiation.H:509
int m_step
Definition: ERF_Radiation.H:288
real2d_k lw_clnclrsky_flux_up
Definition: ERF_Radiation.H:553
amrex::MultiFab datalog_bdy_mf
Definition: ERF_Radiation.H:357
real1d_k lat
Definition: ERF_Radiation.H:511
void populateDatalogMF()
Definition: ERF_Radiation.cpp:977
real2d_k qi_lay
Definition: ERF_Radiation.H:524
real2d_k sw_clrsky_flux_up
Definition: ERF_Radiation.H:547
amrex::Real m_orbital_mvelp
Definition: ERF_Radiation.H:460
real2d_k t_lev
Definition: ERF_Radiation.H:538
amrex::Vector< amrex::Real > m_o3vmr
Definition: ERF_Radiation.H:410
real1d_k o3_lay
Definition: ERF_Radiation.H:499
std::string rrtmgp_cloud_optics_sw
Definition: ERF_Radiation.H:393
real1d_k sfc_alb_dif_vis
Definition: ERF_Radiation.H:505
int m_nlwgpts
Definition: ERF_Radiation.H:478
real1d_k mu0
Definition: ERF_Radiation.H:502
real2d_k cldfrac_tot
Definition: ERF_Radiation.H:525
real1d_k sfc_flux_dir_nir
Definition: ERF_Radiation.H:508
static constexpr int n_flux_sets_optional
Definition: ERF_Radiation.H:365
amrex::MultiFab * m_z_phys
Definition: ERF_Radiation.H:341
static constexpr int n_datalog_nonflux
Definition: ERF_Radiation.H:369
real2d_k sw_clnclrsky_flux_up
Definition: ERF_Radiation.H:544
real3d_k aero_g_sw
Definition: ERF_Radiation.H:583
real2d_k sw_flux_up
Definition: ERF_Radiation.H:539
std::string rrtmgp_cloud_optics_lw
Definition: ERF_Radiation.H:394
amrex::MultiFab * m_rad_fluxes
Definition: ERF_Radiation.H:338
real3d_k sw_bnd_flux_dif
Definition: ERF_Radiation.H:564
real2d_k sfc_alb_dif
Definition: ERF_Radiation.H:572
amrex::Real m_co2vmr
Definition: ERF_Radiation.H:408
bool m_extra_clnsky_diag
Definition: ERF_Radiation.H:442
real1d_k sfc_alb_dif_nir
Definition: ERF_Radiation.H:506
virtual void Init(const amrex::Geometry &geom, const amrex::BoxArray &ba, amrex::MultiFab *cons_in) override
Definition: ERF_Radiation.H:65
real2d_k lw_clnsky_flux_dn
Definition: ERF_Radiation.H:558
void kokkos_buffers_to_mf(const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
Definition: ERF_Radiation.cpp:837
amrex::BoxArray m_ba
Definition: ERF_Radiation.H:300
real2d_k p_lay
Definition: ERF_Radiation.H:519
real2d_k r_lay
Definition: ERF_Radiation.H:518
int m_ncol
Definition: ERF_Radiation.H:429
real2d_k sw_flux_dn_dir
Definition: ERF_Radiation.H:541
const std::vector< amrex::Real > m_mol_weight_gas
Definition: ERF_Radiation.H:404
amrex::Real m_lat_cons
Definition: ERF_Radiation.H:351
static constexpr int max_datalog_flux
Definition: ERF_Radiation.H:366
amrex::Real m_fixed_total_solar_irradiance
Definition: ERF_Radiation.H:465
std::vector< std::string > gas_names_offset
Definition: ERF_Radiation.H:421
real2d_k sw_clrsky_flux_dn
Definition: ERF_Radiation.H:548
virtual amrex::Vector< std::string > get_lsm_input_varnames() override
Definition: ERF_Radiation.H:254
int m_orbital_mon
Definition: ERF_Radiation.H:449
virtual void Run(int &level, int &step, double &time, const double &dt, const amrex::BoxArray &ba, amrex::Geometry &geom, amrex::MultiFab *cons_in, amrex::iMultiFab *lmask, amrex::MultiFab *t_surf, const amrex::Vector< const amrex::MultiFab * > &lsm_input_ptrs, const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs, amrex::MultiFab *qheating_rates, amrex::MultiFab *rad_fluxes, amrex::MultiFab *z_phys, amrex::MultiFab *z_sfc, amrex::MultiFab *lat_ptr, amrex::MultiFab *lon_ptr, const bool force_update, amrex::Real &declin, amrex::Real &calday) override
Definition: ERF_Radiation.H:138
amrex::Real m_declin
Definition: ERF_Radiation.H:471
real3d_k aero_ssa_sw
Definition: ERF_Radiation.H:582
real2d_k sw_clnsky_flux_dn_dir
Definition: ERF_Radiation.H:552
amrex::Real m_o2vmr
Definition: ERF_Radiation.H:414
GasConcsK< amrex::Real, layout_t, KokkosDefaultDevice > m_gas_concs
Definition: ERF_Radiation.H:423
amrex::MultiFab * m_qheating_rates
Definition: ERF_Radiation.H:335
double m_dt
Definition: ERF_Radiation.H:294
real2d_k qc_lay
Definition: ERF_Radiation.H:523
real2d_k lw_clrsky_flux_up
Definition: ERF_Radiation.H:555
amrex::Real m_n2ovmr
Definition: ERF_Radiation.H:411
amrex::Real m_rad_t_sfc
Definition: ERF_Radiation.H:328
static constexpr int n_flux_per_set
Definition: ERF_Radiation.H:363
static constexpr AMREX_GPU_HOST_DEVICE int bdyZtopComp(int nflux)
Definition: ERF_Radiation.H:385
std::string rrtmgp_file_path
Definition: ERF_Radiation.H:390
real2d_k sw_flux_dn
Definition: ERF_Radiation.H:540
int m_nlwbands
Definition: ERF_Radiation.H:476
amrex::MultiFab * m_z_sfc
Definition: ERF_Radiation.H:344
real2d_k lw_clrsky_flux_dn
Definition: ERF_Radiation.H:556
amrex::Real m_orbital_eccen
Definition: ERF_Radiation.H:458
amrex::Real m_covmr
Definition: ERF_Radiation.H:412
int m_orbital_sec
Definition: ERF_Radiation.H:451
real2d_k z_del
Definition: ERF_Radiation.H:521
real3d_k aero_tau_lw
Definition: ERF_Radiation.H:584
int m_ncol_chunk
Definition: ERF_Radiation.H:490
real2d_k lw_flux_dn
Definition: ERF_Radiation.H:543
static constexpr AMREX_GPU_HOST_DEVICE int bdyToaComp(int n, int nflux)
Definition: ERF_Radiation.H:384
~Radiation()
Definition: ERF_Radiation.H:54
real2d_k sw_clrsky_flux_dn_dir
Definition: ERF_Radiation.H:549
void write_rrtmgp_fluxes()
Definition: ERF_Radiation.cpp:937
std::string rrtmgp_coeffs_file_lw
Definition: ERF_Radiation.H:396
int m_lev
Definition: ERF_Radiation.H:285
real1d_k sfc_flux_dif_nir
Definition: ERF_Radiation.H:510
int m_ngas
Definition: ERF_Radiation.H:401
real2d_k lw_heating
Definition: ERF_Radiation.H:531
real1d_k sfc_alb_dir_nir
Definition: ERF_Radiation.H:504
real2d_k lw_clnsky_flux_up
Definition: ERF_Radiation.H:557
amrex::Real m_ch4vmr
Definition: ERF_Radiation.H:413
bool m_update_rad
Definition: ERF_Radiation.H:303
real2d_k sfc_alb_dir
Definition: ERF_Radiation.H:571
bool m_ice
Definition: ERF_Radiation.H:310
amrex::Real m_fixed_solar_zenith_angle
Definition: ERF_Radiation.H:469
static constexpr AMREX_GPU_HOST_DEVICE int bdySfcComp(int n)
Definition: ERF_Radiation.H:383
real1d_k lon
Definition: ERF_Radiation.H:512
int m_orbital_day
Definition: ERF_Radiation.H:450
real1d_k sfc_emis
Definition: ERF_Radiation.H:513
amrex::Real m_orbital_obliq
Definition: ERF_Radiation.H:459
amrex::Real m_n2vmr
Definition: ERF_Radiation.H:415
virtual void WriteDataLog(const double &time) override
Definition: ERF_Radiation.cpp:1163
bool m_fixed_orbital_year
Definition: ERF_Radiation.H:457
real2d_k sw_clnsky_flux_up
Definition: ERF_Radiation.H:550
int m_nlay
Definition: ERF_Radiation.H:430
real3d_k lw_bnd_flux_up
Definition: ERF_Radiation.H:567
int m_nswgpts
Definition: ERF_Radiation.H:477
real1d_k sfc_alb_dir_vis
Definition: ERF_Radiation.H:503
const std::vector< std::string > m_gas_names
Definition: ERF_Radiation.H:402
real2d_k sw_clrsky_heating
Definition: ERF_Radiation.H:532
bool m_extra_clnclrsky_diag
Definition: ERF_Radiation.H:443
real2d_k t_lay
Definition: ERF_Radiation.H:520
real1d_k sfc_flux_dir_vis
Definition: ERF_Radiation.H:507
real2d_k iwp
Definition: ERF_Radiation.H:529
amrex::Geometry m_geom
Definition: ERF_Radiation.H:297
amrex::MultiFab * m_lat
Definition: ERF_Radiation.H:347
amrex::Real m_rdOcp
Definition: ERF_Radiation.H:329
real2d_k p_lev
Definition: ERF_Radiation.H:537
void finalize_impl(const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
Definition: ERF_Radiation.cpp:1615
real2d_k lw_clrsky_heating
Definition: ERF_Radiation.H:533
real2d_k eff_radius_qc
Definition: ERF_Radiation.H:526
int m_rad_nvar
Definition: ERF_Radiation.H:493
amrex::Vector< int > m_col_offsets
Definition: ERF_Radiation.H:433
bool radiation_updated() const override
Reports whether the last radiation call updated its outputs.
Definition: ERF_Radiation.H:181
real1d_k t_sfc
Definition: ERF_Radiation.H:514
void alloc_buffers()
Definition: ERF_Radiation.cpp:344
double m_time
Definition: ERF_Radiation.H:291
amrex::Real m_calday
Definition: ERF_Radiation.H:472
int m_orbital_year
Definition: ERF_Radiation.H:448
real2d_k sw_clnclrsky_flux_dn
Definition: ERF_Radiation.H:545
amrex::Vector< std::string > m_lsm_input_names
Definition: ERF_Radiation.H:317
void rrtmgp_finalize()
Definition: ERF_RRTMGP_Interface.cpp:277
bool initialized
Definition: ERF_RRTMGP_Interface.cpp:25
Definition: ERF_DataStruct.H:743