ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
Radiation Class Reference

#include <ERF_Radiation.H>

Inheritance diagram for Radiation:
Collaboration diagram for Radiation:

Public Member Functions

 Radiation (const int &lev, SolverChoice &sc)
 
 ~Radiation ()
 
virtual void Init (const amrex::Geometry &geom, const amrex::BoxArray &ba, amrex::MultiFab *cons_in) override
 
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
 
bool radiation_updated () const override
 Reports whether the last radiation call updated its outputs. More...
 
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)
 
void alloc_buffers ()
 
void dealloc_buffers ()
 
void mf_to_kokkos_buffers (amrex::iMultiFab *lmask, amrex::MultiFab *t_surf, const amrex::Vector< const amrex::MultiFab * > &lsm_input_ptrs)
 
void kokkos_buffers_to_mf (const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
 
void write_rrtmgp_fluxes ()
 
void initialize_impl ()
 
void run_impl ()
 
void finalize_impl (const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
 
void rad_run_impl (const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
 
virtual amrex::Vector< std::string > get_lsm_input_varnames () override
 
virtual amrex::Vector< std::string > get_lsm_output_varnames () override
 
void populateDatalogMF ()
 
virtual void WriteDataLog (const double &time) override
 
- Public Member Functions inherited from IRadiation
virtual ~IRadiation ()=default
 
void setupDataLog ()
 
void setDataLogFrequency (const int nstep)
 
bool hasDatalog ()
 

Private Member Functions

int nDatalogFluxComp () const
 
int nDatalogComp () const
 
int nDatalogBdyComp () const
 

Static Private Member Functions

static constexpr AMREX_GPU_HOST_DEVICE int bdySfcComp (int n)
 
static constexpr AMREX_GPU_HOST_DEVICE int bdyToaComp (int n, int nflux)
 
static constexpr AMREX_GPU_HOST_DEVICE int bdyZtopComp (int nflux)
 

Private Attributes

bool m_is_nested_patch = false
 
int m_lev = -1
 
int m_step
 
double m_time
 
double m_dt
 
amrex::Geometry m_geom
 
amrex::BoxArray m_ba
 
bool m_update_rad = false
 
bool m_rad_write_fluxes = false
 
bool m_moist = false
 
bool m_ice = false
 
int m_qi_comp = -1
 
bool m_lsm = false
 
amrex::Vector< std::string > m_lsm_input_names
 
amrex::Vector< std::string > m_lsm_output_names
 
amrex::Real m_rad_t_sfc = -1
 
amrex::Real m_rdOcp = RdoCp
 
amrex::MultiFab * m_cons_in = nullptr
 
amrex::MultiFab * m_qheating_rates = nullptr
 
amrex::MultiFab * m_rad_fluxes = nullptr
 
amrex::MultiFab * m_z_phys = nullptr
 
amrex::MultiFab * m_z_sfc = nullptr
 
amrex::MultiFab * m_lat = nullptr
 
amrex::MultiFab * m_lon = nullptr
 
amrex::Real m_lat_cons
 
amrex::Real m_lon_cons
 
amrex::MultiFab datalog_mf
 
amrex::MultiFab datalog_bdy_mf
 
std::string rrtmgp_file_path = "."
 
std::string rrtmgp_coeffs_sw = "rrtmgp-data-sw-g224-2018-12-04.nc"
 
std::string rrtmgp_coeffs_lw = "rrtmgp-data-lw-g256-2018-12-04.nc"
 
std::string rrtmgp_cloud_optics_sw = "rrtmgp-cloud-optics-coeffs-sw.nc"
 
std::string rrtmgp_cloud_optics_lw = "rrtmgp-cloud-optics-coeffs-lw.nc"
 
std::string rrtmgp_coeffs_file_sw
 
std::string rrtmgp_coeffs_file_lw
 
std::string rrtmgp_cloud_optics_file_sw
 
std::string rrtmgp_cloud_optics_file_lw
 
int m_ngas = 8
 
const std::vector< std::string > m_gas_names
 
const std::vector< amrex::Real > m_mol_weight_gas
 
amrex::Real m_co2vmr = amrex::Real(388.717e-6)
 
amrex::Vector< amrex::Real > m_o3vmr {amrex::Real(3.0e-8)}
 
amrex::Real m_n2ovmr = amrex::Real(323.141e-9)
 
amrex::Real m_covmr = amrex::Real(1.0e-7)
 
amrex::Real m_ch4vmr = amrex::Real(1807.851e-9)
 
amrex::Real m_o2vmr = amrex::Real(0.209448)
 
amrex::Real m_n2vmr = amrex::Real(0.7906)
 
int m_o3_size
 
real1d_k m_gas_mol_weights
 
std::vector< std::string > gas_names_offset
 
GasConcsK< amrex::Real, layout_t, KokkosDefaultDevice > m_gas_concs
 
int m_ncol
 
int m_nlay
 
amrex::Vector< int > m_col_offsets
 
bool m_do_aerosol_rad = false
 
bool m_extra_clnsky_diag = false
 
bool m_extra_clnclrsky_diag = false
 
int m_orbital_year = -9999
 
int m_orbital_mon = -9999
 
int m_orbital_day = -9999
 
int m_orbital_sec = -9999
 
bool m_fixed_orbital_year = false
 
amrex::Real m_orbital_eccen = -amrex::Real(9999.)
 
amrex::Real m_orbital_obliq = -amrex::Real(9999.)
 
amrex::Real m_orbital_mvelp = -amrex::Real(9999.)
 
amrex::Real m_fixed_total_solar_irradiance = -amrex::Real(9999.)
 
amrex::Real m_fixed_solar_zenith_angle
 
amrex::Real m_declin = 0.0
 
amrex::Real m_calday = 0.0
 
int m_nswbands
 
int m_nlwbands
 
int m_nswgpts
 
int m_nlwgpts
 
int m_rad_freq_in_steps
 
int m_ncol_chunk_requested = 1024
 
int m_ncol_chunk = 1024
 
int m_rad_nvar = 12
 
bool m_do_subcol_sampling = true
 
real1d_k o3_lay
 
real1d_k mu0
 
real1d_k sfc_alb_dir_vis
 
real1d_k sfc_alb_dir_nir
 
real1d_k sfc_alb_dif_vis
 
real1d_k sfc_alb_dif_nir
 
real1d_k sfc_flux_dir_vis
 
real1d_k sfc_flux_dir_nir
 
real1d_k sfc_flux_dif_vis
 
real1d_k sfc_flux_dif_nir
 
real1d_k lat
 
real1d_k lon
 
real1d_k sfc_emis
 
real1d_k t_sfc
 
real1d_k lw_src
 
real2d_k r_lay
 
real2d_k p_lay
 
real2d_k t_lay
 
real2d_k z_del
 
real2d_k qv_lay
 
real2d_k qc_lay
 
real2d_k qi_lay
 
real2d_k cldfrac_tot
 
real2d_k eff_radius_qc
 
real2d_k eff_radius_qi
 
real2d_k lwp
 
real2d_k iwp
 
real2d_k sw_heating
 
real2d_k lw_heating
 
real2d_k sw_clrsky_heating
 
real2d_k lw_clrsky_heating
 
real2d_k d_tint
 
real2d_k p_lev
 
real2d_k t_lev
 
real2d_k sw_flux_up
 
real2d_k sw_flux_dn
 
real2d_k sw_flux_dn_dir
 
real2d_k lw_flux_up
 
real2d_k lw_flux_dn
 
real2d_k sw_clnclrsky_flux_up
 
real2d_k sw_clnclrsky_flux_dn
 
real2d_k sw_clnclrsky_flux_dn_dir
 
real2d_k sw_clrsky_flux_up
 
real2d_k sw_clrsky_flux_dn
 
real2d_k sw_clrsky_flux_dn_dir
 
real2d_k sw_clnsky_flux_up
 
real2d_k sw_clnsky_flux_dn
 
real2d_k sw_clnsky_flux_dn_dir
 
real2d_k lw_clnclrsky_flux_up
 
real2d_k lw_clnclrsky_flux_dn
 
real2d_k lw_clrsky_flux_up
 
real2d_k lw_clrsky_flux_dn
 
real2d_k lw_clnsky_flux_up
 
real2d_k lw_clnsky_flux_dn
 
real3d_k sw_bnd_flux_up
 
real3d_k sw_bnd_flux_dn
 
real3d_k sw_bnd_flux_dir
 
real3d_k sw_bnd_flux_dif
 
real3d_k lw_bnd_flux_up
 
real3d_k lw_bnd_flux_dn
 
real2d_k sfc_alb_dir
 
real2d_k sfc_alb_dif
 
real3d_k aero_tau_sw
 
real3d_k aero_ssa_sw
 
real3d_k aero_g_sw
 
real3d_k aero_tau_lw
 

Static Private Attributes

static constexpr int n_flux_per_set = 5
 
static constexpr int n_flux_sets_base = 2
 
static constexpr int n_flux_sets_optional = 2
 
static constexpr int max_datalog_flux = n_flux_per_set * (n_flux_sets_base + n_flux_sets_optional)
 
static constexpr int n_datalog_nonflux = 6
 

Additional Inherited Members

- Protected Attributes inherited from IRadiation
std::unique_ptr< std::fstream > datalog = nullptr
 
std::string datalogname
 
int datalog_int = -1
 
- Static Protected Attributes inherited from IRadiation
static constexpr int datalog_width = 14
 
static constexpr int datalog_precision = 9
 
static constexpr int datalog_time_precision = 13
 

Constructor & Destructor Documentation

◆ Radiation()

Radiation::Radiation ( const int &  lev,
SolverChoice &  sc 
)
88 {
89  // Note that Kokkos is now initialized in main.cpp
90 
91  // Stored now, not only in set_grids, so it is valid from construction on
92  m_lev = lev;
93 
94  m_rdOcp = sc.rdOcp;
95 
96  // Check if we have a valid moisture model
97  if (sc.moisture_type != MoistureType::None) { m_moist = true; }
98 
99  // Cloud-ice support follows the configured moisture-component mapping.
101  m_ice = (m_qi_comp >= 0);
102 
103  // Check if we have a land surface model enabled
104  if (sc.lsm_type != LandSurfaceType::None) { m_lsm = true; }
105 
106  // Construct parser object for following reads
107  ParmParse pp("erf");
108 
109  // Must specify a surface temp (LSM can overwrite)
110  pp.get("rad_t_sfc", m_rad_t_sfc);
111 
112  // SolverChoice reads the sun, site and update interval once for RRTMGP
113  // and the optional topographic surface correction.
114  const auto& solar = sc.rrtmgpSolarChoice;
115  m_rad_freq_in_steps = solar.radiation_interval;
116  m_lat_cons = solar.latitude;
117  m_lon_cons = solar.longitude;
118  m_fixed_solar_zenith_angle = solar.fixed_mu;
119 
120  // Get nvar if specified
121  pp.queryAdd("rad_nvar", m_rad_nvar);
123  "erf.rad_nvar must be greater than 0. "
124  "It controls the amount of memory allocated for temporaries with RRTMGP; "
125  "a value of 0 would allocate no memory.");
126 
127  // Number of columns per RRTMGP chunk (controls peak GPU memory)
128  pp.queryAdd("rad_ncol_chunk", m_ncol_chunk_requested);
130  "erf.rad_ncol_chunk must be a positive integer (default 1024). "
131  "It controls the number of columns processed per RRTMGP kernel launch; "
132  "a value of 0 or negative would produce an infinite loop.");
134 
135  // Flag to write fluxes to plt file
136  pp.queryAdd("rad_write_fluxes", m_rad_write_fluxes);
137 
138  // Do MCICA subcolumn sampling
139  pp.queryAdd("rad_do_subcol_sampling", m_do_subcol_sampling);
140 
141  // Determine orbital year. If orbital_year is negative, use current year
142  // from timestamp for orbital year; if non-negative, use provided orbital year
143  // for duration of simulation. Note that this is keyed off the value itself,
144  // not off whether the input was present, so that a negative value defers to
145  // the timestamp as documented.
146  pp.queryAdd("rad_orbital_year", m_orbital_year);
148 
149  // Get orbital parameters from inputs file
150  pp.queryAdd("rad_orbital_eccentricity", m_orbital_eccen);
151  pp.queryAdd("rad_orbital_obliquity" , m_orbital_obliq);
152  pp.queryAdd("rad_orbital_mvelp" , m_orbital_mvelp);
153 
154  // Value for prescribing an invariant solar constant (i.e. total solar irradiance at
155  // TOA). Used for idealized experiments such as RCE. Disabled when value is less than zero
156  pp.queryAdd("fixed_total_solar_irradiance", m_fixed_total_solar_irradiance);
157 
158  // The solar-input range checks live in RRTMGPSolarChoice::read. Surface
159  // temperature is still read and validated by this interface.
160  if (!std::isfinite(m_rad_t_sfc) || m_rad_t_sfc <= Real(0.0)) {
161  amrex::Abort("erf.rad_t_sfc = " + std::to_string(m_rad_t_sfc) +
162  " must be a positive temperature [K].");
163  }
164 
165  // Get prescribed surface values of greenhouse gases
166  pp.queryAdd("co2vmr", m_co2vmr);
167  // The O3 default is a single near-surface value applied to every layer, which
168  // is far too low in the stratosphere; warn so deep runs do not use it silently
169  if (!pp.queryAdd("o3vmr", m_o3vmr) && lev == 0) {
170  // amrex::Warning prints on every rank, so print once from the I/O rank instead
171  amrex::Print() << "WARNING: erf.o3vmr is not set: using " << m_o3vmr[0]
172  << " at every layer. This near-surface value underestimates ozone"
173  " (and shortwave heating) aloft; set erf.o3vmr to a profile for"
174  " domains that reach the stratosphere.\n";
175  }
176  pp.queryAdd("n2ovmr", m_n2ovmr);
177  pp.queryAdd("covmr" , m_covmr );
178  pp.queryAdd("ch4vmr", m_ch4vmr);
179  pp.queryAdd("o2vmr" , m_o2vmr );
180  pp.queryAdd("n2vmr" , m_n2vmr );
181 
182  // Aerosol forcing hook (not implemented). The aerosol arrays that used to be
183  // passed through rrtmgp_main were never populated with real data, so enabling
184  // this flag only ever multiplied radiation by zero aerosol optics. The hook is
185  // kept so a future SPA/prescribed-aerosol scheme can wire in without touching
186  // the ParmParse surface.
187  pp.queryAdd("rad_do_aerosol", m_do_aerosol_rad);
188  if (m_do_aerosol_rad) {
189  amrex::Abort("erf.rad_do_aerosol = true is not supported: aerosol forcing is "
190  "currently not implemented in the ERF RRTMGP interface. The hook "
191  "is retained for a future aerosol coupling; set rad_do_aerosol = "
192  "false (or remove it) to continue.");
193  }
194 
195  // Whether we do extra clean/clear sky calculations
196  pp.queryAdd("rad_extra_clnclrsky_diag", m_extra_clnclrsky_diag);
197  pp.queryAdd("rad_extra_clnsky_diag" , m_extra_clnsky_diag);
198 
199  // Parse path and file names
200  pp.queryAdd("rrtmgp_file_path" , rrtmgp_file_path);
201  pp.queryAdd("rrtmgp_coeffs_sw" , rrtmgp_coeffs_sw );
202  pp.queryAdd("rrtmgp_coeffs_lw" , rrtmgp_coeffs_lw );
203  pp.queryAdd("rrtmgp_cloud_optics_sw", rrtmgp_cloud_optics_sw);
204  pp.queryAdd("rrtmgp_cloud_optics_lw", rrtmgp_cloud_optics_lw);
205 
206  // Fail early, and with a message that names the missing files and the inputs that
207  // control them, rather than letting netCDF report a bare "No such file or directory"
208  // when the coefficients are opened just below (or, for the cloud optics files, much
209  // later inside rrtmgp_initialize). Every rank does this so that all of them abort.
210  check_rrtmgp_data_files(rrtmgp_file_path,
211  {{"rrtmgp_coeffs_sw" , rrtmgp_coeffs_sw },
212  {"rrtmgp_coeffs_lw" , rrtmgp_coeffs_lw },
213  {"rrtmgp_cloud_optics_sw", rrtmgp_cloud_optics_sw},
214  {"rrtmgp_cloud_optics_lw", rrtmgp_cloud_optics_lw}});
215 
216  // Append file names to path
221 
222  // Get dimensions from lookup data
223  if (ParallelDescriptor::IOProcessor()) {
224  auto ncf_sw = ncutils::NCFile::open(rrtmgp_coeffs_file_sw, NC_CLOBBER | NC_NETCDF4);
225  m_nswbands = ncf_sw.dim("bnd").len();
226  m_nswgpts = ncf_sw.dim("gpt").len();
227  ncf_sw.close();
228 
229  auto ncf_lw = ncutils::NCFile::open(rrtmgp_coeffs_file_lw, NC_CLOBBER | NC_NETCDF4);
230  m_nlwbands = ncf_lw.dim("bnd").len();
231  m_nlwgpts = ncf_lw.dim("gpt").len();
232  ncf_lw.close();
233  }
234  int ioproc = ParallelDescriptor::IOProcessorNumber(); // I/O rank
235  ParallelDescriptor::Bcast(&m_nswbands, 1, ioproc);
236  ParallelDescriptor::Bcast(&m_nlwbands, 1, ioproc);
237  ParallelDescriptor::Bcast(&m_nswgpts, 1, ioproc);
238  ParallelDescriptor::Bcast(&m_nlwgpts, 1, ioproc);
239 
240  // Output for user
241  if (lev == 0) {
242  Print() << "Radiation interface constructed:\n";
243  Print() << "========================================================\n";
244  Print() << "Coeff SW file: " << rrtmgp_coeffs_file_sw << "\n";
245  Print() << "Coeff LW file: " << rrtmgp_coeffs_file_lw << "\n";
246  Print() << "Cloud SW file: " << rrtmgp_cloud_optics_file_sw << "\n";
247  Print() << "Cloud LW file: " << rrtmgp_cloud_optics_file_lw << "\n";
248  Print() << "Number of short/longwave bands: "
249  << m_nswbands << " " << m_nlwbands << "\n";
250  Print() << "Number of short/longwave gauss points: "
251  << m_nswgpts << " " << m_nlwgpts << "\n";
252  Print() << "========================================================\n";
253  }
254 }
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
ParmParse pp("prob")
std::string rrtmgp_coeffs_file_sw
Definition: ERF_Radiation.H:395
std::string rrtmgp_coeffs_sw
Definition: ERF_Radiation.H:391
int m_rad_freq_in_steps
Definition: ERF_Radiation.H:481
amrex::Real m_lon_cons
Definition: ERF_Radiation.H:352
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
bool m_moist
Definition: ERF_Radiation.H:309
std::string rrtmgp_cloud_optics_file_lw
Definition: ERF_Radiation.H:398
int m_ncol_chunk_requested
Definition: ERF_Radiation.H:489
bool m_lsm
Definition: ERF_Radiation.H:314
bool m_do_subcol_sampling
Definition: ERF_Radiation.H:496
bool m_rad_write_fluxes
Definition: ERF_Radiation.H:306
int m_qi_comp
Definition: ERF_Radiation.H:311
std::string rrtmgp_cloud_optics_file_sw
Definition: ERF_Radiation.H:397
amrex::Real m_orbital_mvelp
Definition: ERF_Radiation.H:460
amrex::Vector< amrex::Real > m_o3vmr
Definition: ERF_Radiation.H:410
std::string rrtmgp_cloud_optics_sw
Definition: ERF_Radiation.H:393
int m_nlwgpts
Definition: ERF_Radiation.H:478
std::string rrtmgp_cloud_optics_lw
Definition: ERF_Radiation.H:394
amrex::Real m_co2vmr
Definition: ERF_Radiation.H:408
bool m_extra_clnsky_diag
Definition: ERF_Radiation.H:442
amrex::Real m_lat_cons
Definition: ERF_Radiation.H:351
amrex::Real m_fixed_total_solar_irradiance
Definition: ERF_Radiation.H:465
amrex::Real m_o2vmr
Definition: ERF_Radiation.H:414
amrex::Real m_n2ovmr
Definition: ERF_Radiation.H:411
amrex::Real m_rad_t_sfc
Definition: ERF_Radiation.H:328
std::string rrtmgp_file_path
Definition: ERF_Radiation.H:390
int m_nlwbands
Definition: ERF_Radiation.H:476
amrex::Real m_orbital_eccen
Definition: ERF_Radiation.H:458
amrex::Real m_covmr
Definition: ERF_Radiation.H:412
int m_ncol_chunk
Definition: ERF_Radiation.H:490
std::string rrtmgp_coeffs_file_lw
Definition: ERF_Radiation.H:396
int m_lev
Definition: ERF_Radiation.H:285
amrex::Real m_ch4vmr
Definition: ERF_Radiation.H:413
bool m_ice
Definition: ERF_Radiation.H:310
amrex::Real m_fixed_solar_zenith_angle
Definition: ERF_Radiation.H:469
amrex::Real m_orbital_obliq
Definition: ERF_Radiation.H:459
amrex::Real m_n2vmr
Definition: ERF_Radiation.H:415
bool m_fixed_orbital_year
Definition: ERF_Radiation.H:457
int m_nswgpts
Definition: ERF_Radiation.H:477
bool m_extra_clnclrsky_diag
Definition: ERF_Radiation.H:443
amrex::Real m_rdOcp
Definition: ERF_Radiation.H:329
int m_rad_nvar
Definition: ERF_Radiation.H:493
int m_orbital_year
Definition: ERF_Radiation.H:448
@ None
Definition: ERF_LSM_Types.H:6
int qi
cloud ice
Definition: ERF_DataStruct.H:292
MoistureType moisture_type
Moisture or microphysics model.
Definition: ERF_DataStruct.H:3433
amrex::Real rdOcp
Ratio of dry-air gas constant to c_p.
Definition: ERF_DataStruct.H:3150
RRTMGPSolarChoice rrtmgpSolarChoice
Definition: ERF_DataStruct.H:3023
LandSurfaceType lsm_type
Land-surface model.
Definition: ERF_DataStruct.H:3462
MoistureComponentIndices moisture_indices
Index map of the moisture data carried by the active scheme: conserved-state components for the speci...
Definition: ERF_DataStruct.H:3504
Here is the call graph for this function:

◆ ~Radiation()

Radiation::~Radiation ( )
inline
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  }
void rrtmgp_finalize()
Definition: ERF_RRTMGP_Interface.cpp:277
bool initialized
Definition: ERF_RRTMGP_Interface.cpp:25
Here is the call graph for this function:

Member Function Documentation

◆ alloc_buffers()

void Radiation::alloc_buffers ( )
345 {
346  // 1d size (m_ngas)
347  const Real* mol_weight_gas_p = m_mol_weight_gas.data();
348  const std::string* gas_names_p = m_gas_names.data();
349  m_gas_mol_weights = real1d_k("m_gas_mol_weights", m_ngas);
350  realHost1d_k m_gas_mol_weights_h("m_gas_mol_weights_h", m_ngas);
351  gas_names_offset.clear(); gas_names_offset.resize(m_ngas);
352  std::string* gas_names_offset_p = gas_names_offset.data();
353  Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::Serial>(0, m_ngas),
354  [&] (int igas)
355  {
356  m_gas_mol_weights_h(igas) = mol_weight_gas_p[igas];
357  gas_names_offset_p[igas] = gas_names_p[igas];
358  });
359  Kokkos::deep_copy(m_gas_mol_weights, m_gas_mol_weights_h);
360 
361  // 1d size (1 or nlay)
362  m_o3_size = m_o3vmr.size();
364  "erf.o3vmr must have 1 or nlay values");
365  Real* o3vmr_p = m_o3vmr.data();
366  o3_lay = real1d_k("o3_lay", m_o3_size);
367  realHost1d_k o3_lay_h("o3_lay_h", m_o3_size);
368  Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::Serial>(0, m_o3_size),
369  [&] (int io3)
370  {
371  o3_lay_h(io3) = o3vmr_p[io3];
372  });
373  Kokkos::deep_copy(o3_lay, o3_lay_h);
374 
375  // 1d size (ncol)
376  mu0 = real1d_k("mu0" , m_ncol);
377  sfc_alb_dir_vis = real1d_k("sfc_alb_dir_vis" , m_ncol);
378  sfc_alb_dir_nir = real1d_k("sfc_alb_dir_nir" , m_ncol);
379  sfc_alb_dif_vis = real1d_k("sfc_alb_dif_vis" , m_ncol);
380  sfc_alb_dif_nir = real1d_k("sfc_alb_dif_nir" , m_ncol);
381  sfc_flux_dir_vis = real1d_k("sfc_flux_dir_vis", m_ncol);
382  sfc_flux_dir_nir = real1d_k("sfc_flux_dir_nir", m_ncol);
383  sfc_flux_dif_vis = real1d_k("sfc_flux_dif_vis", m_ncol);
384  sfc_flux_dif_nir = real1d_k("sfc_flux_dif_nir", m_ncol);
385  lat = real1d_k("lat" , m_ncol);
386  lon = real1d_k("lon" , m_ncol);
387  sfc_emis = real1d_k("sfc_emis" , m_ncol);
388  t_sfc = real1d_k("t_sfc" , m_ncol);
389  lw_src = real1d_k("lw_src" , m_ncol);
390 
391  // 2d size (ncol, nlay)
392  r_lay = real2d_k("r_lay" , m_ncol, m_nlay);
393  p_lay = real2d_k("p_lay" , m_ncol, m_nlay);
394  t_lay = real2d_k("t_lay" , m_ncol, m_nlay);
395  z_del = real2d_k("z_del" , m_ncol, m_nlay);
396  qv_lay = real2d_k("qv" , m_ncol, m_nlay);
397  qc_lay = real2d_k("qc" , m_ncol, m_nlay);
398  qi_lay = real2d_k("qi" , m_ncol, m_nlay);
399  cldfrac_tot = real2d_k("cldfrac_tot" , m_ncol, m_nlay);
400  eff_radius_qc = real2d_k("eff_radius_qc", m_ncol, m_nlay);
401  eff_radius_qi = real2d_k("eff_radius_qi", m_ncol, m_nlay);
402  lwp = real2d_k("lwp" , m_ncol, m_nlay);
403  iwp = real2d_k("iwp" , m_ncol, m_nlay);
404  sw_heating = real2d_k("sw_heating" , m_ncol, m_nlay);
405  lw_heating = real2d_k("lw_heating" , m_ncol, m_nlay);
406  if (datalog_int > 0) {
407  sw_clrsky_heating = real2d_k("sw_clrsky_heating", m_ncol, m_nlay);
408  lw_clrsky_heating = real2d_k("lw_clrsky_heating", m_ncol, m_nlay);
409  }
410 
411  // 2d size (ncol, nlay+1)
412  d_tint = real2d_k("d_tint" , m_ncol, m_nlay+1);
413  p_lev = real2d_k("p_lev" , m_ncol, m_nlay+1);
414  t_lev = real2d_k("t_lev" , m_ncol, m_nlay+1);
415 
416  sw_flux_up = real2d_k("sw_flux_up" , m_ncol, m_nlay+1);
417  sw_flux_dn = real2d_k("sw_flux_dn" , m_ncol, m_nlay+1);
418  sw_flux_dn_dir = real2d_k("sw_flux_dn_dir" , m_ncol, m_nlay+1);
419 
420  lw_flux_up = real2d_k("lw_flux_up" , m_ncol, m_nlay+1);
421  lw_flux_dn = real2d_k("lw_flux_dn" , m_ncol, m_nlay+1);
422 
423  // Clear-sky flux arrays are always needed
424  if (datalog_int > 0) {
425  sw_clrsky_flux_up = real2d_k("sw_clrsky_flux_up" , m_ncol, m_nlay+1);
426  sw_clrsky_flux_dn = real2d_k("sw_clrsky_flux_dn" , m_ncol, m_nlay+1);
427  sw_clrsky_flux_dn_dir = real2d_k("sw_clrsky_flux_dn_dir", m_ncol, m_nlay+1);
428  lw_clrsky_flux_up = real2d_k("lw_clrsky_flux_up" , m_ncol, m_nlay+1);
429  lw_clrsky_flux_dn = real2d_k("lw_clrsky_flux_dn" , m_ncol, m_nlay+1);
430  } else {
431  // Use m_ncol_chunk_requested to prevent pool shrinkage after regrid
432  sw_clrsky_flux_up = real2d_k("sw_clrsky_flux_up" , m_ncol_chunk_requested, m_nlay+1);
433  sw_clrsky_flux_dn = real2d_k("sw_clrsky_flux_dn" , m_ncol_chunk_requested, m_nlay+1);
434  sw_clrsky_flux_dn_dir = real2d_k("sw_clrsky_flux_dn_dir", m_ncol_chunk_requested, m_nlay+1);
435  lw_clrsky_flux_up = real2d_k("lw_clrsky_flux_up" , m_ncol_chunk_requested, m_nlay+1);
436  lw_clrsky_flux_dn = real2d_k("lw_clrsky_flux_dn" , m_ncol_chunk_requested, m_nlay+1);
437  }
438 
439  // Clean-clear-sky diagnostic fluxes (only when enabled)
441  sw_clnclrsky_flux_up = real2d_k("sw_clnclrsky_flux_up" , m_ncol, m_nlay+1);
442  sw_clnclrsky_flux_dn = real2d_k("sw_clnclrsky_flux_dn" , m_ncol, m_nlay+1);
443  sw_clnclrsky_flux_dn_dir = real2d_k("sw_clnclrsky_flux_dn_dir", m_ncol, m_nlay+1);
444  lw_clnclrsky_flux_up = real2d_k("lw_clnclrsky_flux_up" , m_ncol, m_nlay+1);
445  lw_clnclrsky_flux_dn = real2d_k("lw_clnclrsky_flux_dn" , m_ncol, m_nlay+1);
446  } else {
447  sw_clnclrsky_flux_up = real2d_k("sw_clnclrsky_flux_up" , 1, 1);
448  sw_clnclrsky_flux_dn = real2d_k("sw_clnclrsky_flux_dn" , 1, 1);
449  sw_clnclrsky_flux_dn_dir = real2d_k("sw_clnclrsky_flux_dn_dir", 1, 1);
450  lw_clnclrsky_flux_up = real2d_k("lw_clnclrsky_flux_up" , 1, 1);
451  lw_clnclrsky_flux_dn = real2d_k("lw_clnclrsky_flux_dn" , 1, 1);
452  }
453 
454  // Clean-sky diagnostic fluxes (only when enabled)
455  if (m_extra_clnsky_diag) {
456  sw_clnsky_flux_up = real2d_k("sw_clnsky_flux_up" , m_ncol, m_nlay+1);
457  sw_clnsky_flux_dn = real2d_k("sw_clnsky_flux_dn" , m_ncol, m_nlay+1);
458  sw_clnsky_flux_dn_dir = real2d_k("sw_clnsky_flux_dn_dir" , m_ncol, m_nlay+1);
459  lw_clnsky_flux_up = real2d_k("lw_clnsky_flux_up" , m_ncol, m_nlay+1);
460  lw_clnsky_flux_dn = real2d_k("lw_clnsky_flux_dn" , m_ncol, m_nlay+1);
461  } else {
462  sw_clnsky_flux_up = real2d_k("sw_clnsky_flux_up" , 1, 1);
463  sw_clnsky_flux_dn = real2d_k("sw_clnsky_flux_dn" , 1, 1);
464  sw_clnsky_flux_dn_dir = real2d_k("sw_clnsky_flux_dn_dir" , 1, 1);
465  lw_clnsky_flux_up = real2d_k("lw_clnsky_flux_up" , 1, 1);
466  lw_clnsky_flux_dn = real2d_k("lw_clnsky_flux_dn" , 1, 1);
467  }
468 
469  // 3d size (ncol_chunk, nlay+1, nswbands)
470  // Use m_ncol_chunk_requested to prevent pool shrinkage after regrid
475 
476  // 3d size (ncol_chunk, nlay+1, nlwbands)
477  // Use m_ncol_chunk_requested to prevent pool shrinkage after regrid
480 
481  // 2d size (ncol, nswbands)
482  sfc_alb_dir = real2d_k("sfc_alb_dir", m_ncol, m_nswbands);
483  sfc_alb_dif = real2d_k("sfc_alb_dif", m_ncol, m_nswbands);
484 
485  // Aerosol optical properties — allocated only when aerosol coupling is on.
486  // The flag gates allocation so today (coupling not implemented, abort fires
487  // in the constructor) these stay as empty Views and cost nothing. When a
488  // future aerosol scheme populates them, hook up the plumbing into
489  // rrtmgp_main as well.
490  if (m_do_aerosol_rad) {
491  aero_tau_sw = real3d_k("aero_tau_sw", m_ncol, m_nlay, m_nswbands);
492  aero_ssa_sw = real3d_k("aero_ssa_sw", m_ncol, m_nlay, m_nswbands);
493  aero_g_sw = real3d_k("aero_g_sw", m_ncol, m_nlay, m_nswbands);
494  aero_tau_lw = real3d_k("aero_tau_lw", m_ncol, m_nlay, m_nlwbands);
495  }
496 }
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
Kokkos::View< RealT *, KokkosHostDevice > realHost1d_k
Definition: ERF_Kokkos.H:16
int datalog_int
Definition: ERF_RadiationInterface.H:114
real3d_k sw_bnd_flux_dn
Definition: ERF_Radiation.H:562
real2d_k lw_flux_up
Definition: ERF_Radiation.H:542
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
real2d_k d_tint
Definition: ERF_Radiation.H:536
real2d_k lw_clnclrsky_flux_dn
Definition: ERF_Radiation.H:554
real2d_k lwp
Definition: ERF_Radiation.H:528
real1d_k lw_src
Definition: ERF_Radiation.H:515
real2d_k eff_radius_qi
Definition: ERF_Radiation.H:527
real1d_k m_gas_mol_weights
Definition: ERF_Radiation.H:420
real2d_k sw_heating
Definition: ERF_Radiation.H:530
real3d_k lw_bnd_flux_dn
Definition: ERF_Radiation.H:568
real3d_k sw_bnd_flux_up
Definition: ERF_Radiation.H:561
real2d_k qv_lay
Definition: ERF_Radiation.H:522
real2d_k sw_clnclrsky_flux_dn_dir
Definition: ERF_Radiation.H:546
real1d_k sfc_flux_dif_vis
Definition: ERF_Radiation.H:509
real2d_k lw_clnclrsky_flux_up
Definition: ERF_Radiation.H:553
real1d_k lat
Definition: ERF_Radiation.H:511
real2d_k qi_lay
Definition: ERF_Radiation.H:524
real2d_k sw_clrsky_flux_up
Definition: ERF_Radiation.H:547
real2d_k t_lev
Definition: ERF_Radiation.H:538
real1d_k o3_lay
Definition: ERF_Radiation.H:499
real1d_k sfc_alb_dif_vis
Definition: ERF_Radiation.H:505
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
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
real3d_k sw_bnd_flux_dif
Definition: ERF_Radiation.H:564
real2d_k sfc_alb_dif
Definition: ERF_Radiation.H:572
real1d_k sfc_alb_dif_nir
Definition: ERF_Radiation.H:506
real2d_k lw_clnsky_flux_dn
Definition: ERF_Radiation.H:558
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
std::vector< std::string > gas_names_offset
Definition: ERF_Radiation.H:421
real2d_k sw_clrsky_flux_dn
Definition: ERF_Radiation.H:548
real3d_k aero_ssa_sw
Definition: ERF_Radiation.H:582
real2d_k sw_clnsky_flux_dn_dir
Definition: ERF_Radiation.H:552
real2d_k qc_lay
Definition: ERF_Radiation.H:523
real2d_k lw_clrsky_flux_up
Definition: ERF_Radiation.H:555
real2d_k sw_flux_dn
Definition: ERF_Radiation.H:540
real2d_k lw_clrsky_flux_dn
Definition: ERF_Radiation.H:556
real2d_k z_del
Definition: ERF_Radiation.H:521
real3d_k aero_tau_lw
Definition: ERF_Radiation.H:584
real2d_k lw_flux_dn
Definition: ERF_Radiation.H:543
real2d_k sw_clrsky_flux_dn_dir
Definition: ERF_Radiation.H:549
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
real2d_k sfc_alb_dir
Definition: ERF_Radiation.H:571
real1d_k lon
Definition: ERF_Radiation.H:512
real1d_k sfc_emis
Definition: ERF_Radiation.H:513
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
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
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
real2d_k p_lev
Definition: ERF_Radiation.H:537
real2d_k lw_clrsky_heating
Definition: ERF_Radiation.H:533
real2d_k eff_radius_qc
Definition: ERF_Radiation.H:526
real1d_k t_sfc
Definition: ERF_Radiation.H:514
real2d_k sw_clnclrsky_flux_dn
Definition: ERF_Radiation.H:545
Here is the call graph for this function:

◆ bdySfcComp()

static constexpr AMREX_GPU_HOST_DEVICE int Radiation::bdySfcComp ( int  n)
inlinestaticconstexprprivate
383 { return n; }

◆ bdyToaComp()

static constexpr AMREX_GPU_HOST_DEVICE int Radiation::bdyToaComp ( int  n,
int  nflux 
)
inlinestaticconstexprprivate
384 { return nflux + n; }

◆ bdyZtopComp()

static constexpr AMREX_GPU_HOST_DEVICE int Radiation::bdyZtopComp ( int  nflux)
inlinestaticconstexprprivate
385 { return 2*nflux; }

Referenced by nDatalogBdyComp().

Here is the caller graph for this function:

◆ dealloc_buffers()

void Radiation::dealloc_buffers ( )
500 {
501  // 1d size (m_ngas)
503 
504  // 1d size (1 or nlay)
505  o3_lay = real1d_k();
506 
507  // 1d size (ncol)
508  mu0 = real1d_k();
517  lat = real1d_k();
518  lon = real1d_k();
519  sfc_emis = real1d_k();
520  t_sfc = real1d_k();
521  lw_src = real1d_k();
522 
523  // 2d size (ncol, nlay)
524  r_lay = real2d_k();
525  p_lay = real2d_k();
526  t_lay = real2d_k();
527  z_del = real2d_k();
528  qv_lay = real2d_k();
529  qc_lay = real2d_k();
530  qi_lay = real2d_k();
531  cldfrac_tot = real2d_k();
534  lwp = real2d_k();
535  iwp = real2d_k();
536  sw_heating = real2d_k();
537  lw_heating = real2d_k();
540 
541  // 2d size (ncol, nlay+1)
542  d_tint = real2d_k();
543  p_lev = real2d_k();
544  t_lev = real2d_k();
545  sw_flux_up = real2d_k();
546  sw_flux_dn = real2d_k();
548  lw_flux_up = real2d_k();
549  lw_flux_dn = real2d_k();
565 
566  // 3d size (ncol, nlay+1, nswbands)
571 
572  // 3d size (ncol, nlay+1, nlwbands)
575 
576  // 2d size (ncol, nswbands)
577  sfc_alb_dir = real2d_k();
578  sfc_alb_dif = real2d_k();
579 
580  // Aerosol scaffolding (no-op unless m_do_aerosol_rad enabled allocation above)
581  aero_tau_sw = real3d_k();
582  aero_ssa_sw = real3d_k();
583  aero_g_sw = real3d_k();
584  aero_tau_lw = real3d_k();
585 }

◆ finalize_impl()

void Radiation::finalize_impl ( const amrex::Vector< amrex::MultiFab * > &  lsm_output_ptrs)
1616 {
1617  // Reset gas concentrations (k-dist data persists across steps)
1618  m_gas_concs.reset();
1619 
1620  // Fill the AMReX MFs from Kokkos Views
1621  kokkos_buffers_to_mf(lsm_output_ptrs);
1622 
1623  // Write fluxes if requested
1625 
1626  // Fill output data for datalog before deallocating
1627  if (datalog_int > 0) {
1630  Kokkos::fence();
1632  }
1633 
1634  // Deallocate the buffer arrays
1635  dealloc_buffers();
1636 }
void dealloc_buffers()
Definition: ERF_Radiation.cpp:499
void populateDatalogMF()
Definition: ERF_Radiation.cpp:977
void kokkos_buffers_to_mf(const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
Definition: ERF_Radiation.cpp:837
GasConcsK< amrex::Real, layout_t, KokkosDefaultDevice > m_gas_concs
Definition: ERF_Radiation.H:423
void write_rrtmgp_fluxes()
Definition: ERF_Radiation.cpp:937
void compute_heating_rate(View1 const &flux_up, View2 const &flux_dn, View3 const &rho, View4 const &dz, View5 &heating_rate)
Definition: ERF_RRTMGP_Utils.H:81

Referenced by rad_run_impl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_lsm_input_varnames()

virtual amrex::Vector<std::string> Radiation::get_lsm_input_varnames ( )
inlineoverridevirtual

Reimplemented from IRadiation.

255  {
256  return m_lsm_input_names;
257  }
amrex::Vector< std::string > m_lsm_input_names
Definition: ERF_Radiation.H:317

◆ get_lsm_output_varnames()

virtual amrex::Vector<std::string> Radiation::get_lsm_output_varnames ( )
inlineoverridevirtual

Reimplemented from IRadiation.

263  {
264  return m_lsm_output_names;
265  }
amrex::Vector< std::string > m_lsm_output_names
Definition: ERF_Radiation.H:322

◆ Init()

virtual void Radiation::Init ( const amrex::Geometry &  geom,
const amrex::BoxArray &  ba,
amrex::MultiFab *  cons_in 
)
inlineoverridevirtual

Implements IRadiation.

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  };
const int nx
Definition: ERF_InitCustomPertVels_CloudChamber.H:14
const int ny
Definition: ERF_InitCustomPertVels_CloudChamber.H:15
bool rad_boxes_span_column(const amrex::BoxArray &ba, const amrex::Box &dom)
Definition: ERF_RadiationInterface.H:18
bool m_is_nested_patch
Definition: ERF_Radiation.H:282
amrex::Vector< int > m_col_offsets
Definition: ERF_Radiation.H:433
Here is the call graph for this function:

◆ initialize_impl()

void Radiation::initialize_impl ( )
1293 {
1294  // Initialize gas concentrations for this step
1296 
1297  // Load k-distribution and cloud optics data only once.
1298  // These are static lookup tables that never change.
1299  // Size the memory pool for the requested chunk size (not the effective one, and
1300  // not min with the current m_ncol) so that the pool remains valid even if m_ncol
1301  // grows after regridding/load balancing. The pool is created once and never
1302  // resized, whereas the effective chunk size is recomputed at every Init() and is
1303  // bounded above by the request.
1304  if (!rrtmgp::initialized) {
1305  gas_concs_t gas_concs_pool;
1306  gas_concs_pool.init(gas_names_offset, m_ncol_chunk_requested, m_nlay);
1307  rrtmgp::rrtmgp_initialize(gas_concs_pool,
1310  m_rad_nvar);
1311  gas_concs_pool.reset();
1312  }
1313 }
GasConcsK< RealT, layout_t, KokkosDefaultDevice > gas_concs_t
Definition: ERF_RRTMGP_Interface.H:31
void rrtmgp_initialize(gas_concs_t &gas_concs_k, const std::string &coefficients_file_sw, const std::string &coefficients_file_lw, const std::string &cloud_optics_file_sw, const std::string &cloud_optics_file_lw, const int &nvar)
Definition: ERF_RRTMGP_Interface.cpp:237

Referenced by rad_run_impl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kokkos_buffers_to_mf()

void Radiation::kokkos_buffers_to_mf ( const amrex::Vector< amrex::MultiFab * > &  lsm_output_ptrs)
838 {
839  // The heating rates and fluxes read below were written by Kokkos kernels in run_impl().
840  // Kokkos launches on its own default instance while the ParallelFors here launch on
841  // amrex::Gpu::gpuStream(), and nothing orders the consumer against the producer: MFIter
842  // synchronizes the streams it used, but only after its own kernels, which is too late.
843  // This is the same cross-stream race that made radqrclw vary run to run in the datalog
844  // path (see section 7 of RRTMGP_Memory_Reduction.md); that fence guarded one call site,
845  // this one guards the hand-off that feeds qheating_rates and rad_fluxes back into the
846  // solution. No-op on a CPU build.
847  Kokkos::fence();
848 
849  // Heating rate, fluxes, zenith, lsm ptrs
850 
851  Table2D<Real,Order::C> p_lay_tab(p_lay.data(), {0,0}, {static_cast<int>(p_lay.extent(0)),static_cast<int>(p_lay.extent(1))});
852  Table2D<Real,Order::C> sw_heating_tab(sw_heating.data(), {0,0}, {static_cast<int>(sw_heating.extent(0)),static_cast<int>(sw_heating.extent(1))});
853  Table2D<Real,Order::C> lw_heating_tab(lw_heating.data(), {0,0}, {static_cast<int>(lw_heating.extent(0)),static_cast<int>(lw_heating.extent(1))});
854  Table2D<Real,Order::C> sw_flux_up_tab(sw_flux_up.data(), {0,0}, {static_cast<int>(sw_flux_up.extent(0)),static_cast<int>(sw_flux_up.extent(1))});
855  Table2D<Real,Order::C> sw_flux_dn_tab(sw_flux_dn.data(), {0,0}, {static_cast<int>(sw_flux_dn.extent(0)),static_cast<int>(sw_flux_dn.extent(1))});
856  Table2D<Real,Order::C> lw_flux_up_tab(lw_flux_up.data(), {0,0}, {static_cast<int>(lw_flux_up.extent(0)),static_cast<int>(lw_flux_up.extent(1))});
857  Table2D<Real,Order::C> lw_flux_dn_tab(lw_flux_dn.data(), {0,0}, {static_cast<int>(lw_flux_dn.extent(0)),static_cast<int>(lw_flux_dn.extent(1))});
858 
859  TableData<Real,1> sfc_flux_sw_dn; sfc_flux_sw_dn.resize({0}, {static_cast<int>(sw_flux_dn.extent(0))});
860  TableData<Real,1> sfc_flux_lw_dn; sfc_flux_lw_dn.resize({0}, {static_cast<int>(lw_flux_dn.extent(0))});
861  Table1D<Real> sfc_flux_sw_dn_tab = sfc_flux_sw_dn.table();
862  Table1D<Real> sfc_flux_lw_dn_tab = sfc_flux_lw_dn.table();
863  Table1D<Real> sfc_flux_sw_dir_vis_tab(sfc_flux_dir_vis.data(), {0}, {static_cast<int>(sfc_flux_dir_vis.extent(0))});
864  Table1D<Real> sfc_flux_sw_dir_nir_tab(sfc_flux_dir_nir.data(), {0}, {static_cast<int>(sfc_flux_dir_nir.extent(0))});
865  Table1D<Real> sfc_flux_sw_dif_vis_tab(sfc_flux_dif_vis.data(), {0}, {static_cast<int>(sfc_flux_dif_vis.extent(0))});
866  Table1D<Real> sfc_flux_sw_dif_nir_tab(sfc_flux_dif_nir.data(), {0}, {static_cast<int>(sfc_flux_dif_nir.extent(0))});
867  Table1D<Real> mu0_tab(mu0.data(), {0}, {static_cast<int>(mu0.extent(0))});
868  Vector<Table1D<Real>> rrtmgp_out_vars = {mu0_tab , sfc_flux_sw_dn_tab ,
869  sfc_flux_sw_dir_vis_tab, sfc_flux_sw_dir_nir_tab,
870  sfc_flux_sw_dif_vis_tab, sfc_flux_sw_dif_nir_tab,
871  sfc_flux_lw_dn_tab };
872 
873  const Real rdOcp = m_rdOcp;
874  for (MFIter mfi(*m_cons_in); mfi.isValid(); ++mfi) {
875  const auto& vbx = mfi.validbox();
876  const auto& sbx = makeSlab(vbx,2,vbx.smallEnd(2));
877  const int nx = vbx.length(0);
878  const int imin = vbx.smallEnd(0);
879  const int jmin = vbx.smallEnd(1);
880  const int ktop = vbx.bigEnd(2);
881  const int offset = m_col_offsets[mfi.index()];
882  const Array4<Real>& q_arr = m_qheating_rates->array(mfi);
883  const Array4<Real>& f_arr = m_rad_fluxes->array(mfi);
884  ParallelFor(vbx, [=]
885  AMREX_GPU_DEVICE (int i, int j, int k)
886  {
887  // map [i,j,k] 0-based to [icol, ilay] 0-based
888  const int icol = (j-jmin)*nx + (i-imin) + offset;
889  const int ilay = k;
890 
891  // Temperature heating rate for SW and LW
892  q_arr(i,j,k,0) = sw_heating_tab(icol,ilay);
893  q_arr(i,j,k,1) = lw_heating_tab(icol,ilay);
894 
895  // Convert the dT/dz to dTheta/dz
896  Real iexner = rrtmgp::inverse_exner(Real(p_lay_tab(icol,ilay)), rdOcp);
897  q_arr(i,j,k,0) *= iexner;
898  q_arr(i,j,k,1) *= iexner;
899 
900  // Populate the fluxes: level ilay is the lower interface of
901  // layer k, and the top-of-atmosphere level nlay goes into the
902  // z-ghost cell above the top layer (rad_fluxes has one).
903  f_arr(i,j,k,0) = sw_flux_up_tab(icol,ilay);
904  f_arr(i,j,k,1) = sw_flux_dn_tab(icol,ilay);
905  f_arr(i,j,k,2) = lw_flux_up_tab(icol,ilay);
906  f_arr(i,j,k,3) = lw_flux_dn_tab(icol,ilay);
907  if (k == ktop) {
908  f_arr(i,j,k+1,0) = sw_flux_up_tab(icol,ilay+1);
909  f_arr(i,j,k+1,1) = sw_flux_dn_tab(icol,ilay+1);
910  f_arr(i,j,k+1,2) = lw_flux_up_tab(icol,ilay+1);
911  f_arr(i,j,k+1,3) = lw_flux_dn_tab(icol,ilay+1);
912  }
913 
914  if (k==0) {
915  sfc_flux_sw_dn_tab(icol) = sw_flux_dn_tab(icol,ilay);
916  sfc_flux_lw_dn_tab(icol) = lw_flux_dn_tab(icol,ilay);
917  }
918  });
919  for (int ivar(0); ivar<lsm_output_ptrs.size(); ivar++) {
920  if (lsm_output_ptrs[ivar]) {
921  auto rrtmgp_for_fill = rrtmgp_out_vars[ivar];
922  const Array4<Real>& lsm_out_arr = lsm_output_ptrs[ivar]->array(mfi);
923  ParallelFor(sbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
924  {
925  // map [i,j,k] 0-based to [icol, ilay] 0-based
926  const int icol = (j-jmin)*nx + (i-imin) + offset;
927 
928  // export the desired variable at surface
929  lsm_out_arr(i,j,k) = rrtmgp_for_fill(icol);
930  });
931  } // valid ptr
932  } // ivar
933  }// mfi
934 }
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128
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);})
AMREX_FORCE_INLINE IntVect offset(const int face_dir, const int normal)
Definition: ERF_ReadBndryPlanes.cpp:36
amrex::MultiFab * m_cons_in
Definition: ERF_Radiation.H:332
amrex::MultiFab * m_rad_fluxes
Definition: ERF_Radiation.H:338
amrex::MultiFab * m_qheating_rates
Definition: ERF_Radiation.H:335
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real inverse_exner(const amrex::Real pressure, const amrex::Real rdOcp)
Definition: ERF_RRTMGP_SurfaceTemperature.H:12
Here is the call graph for this function:

◆ mf_to_kokkos_buffers()

void Radiation::mf_to_kokkos_buffers ( amrex::iMultiFab *  lmask,
amrex::MultiFab *  t_surf,
const amrex::Vector< const amrex::MultiFab * > &  lsm_input_ptrs 
)
592 {
593  Table2D<Real,Order::C> r_lay_tab(r_lay.data(), {0,0}, {static_cast<int>(r_lay.extent(0)),static_cast<int>(r_lay.extent(1))});
594  Table2D<Real,Order::C> p_lay_tab(p_lay.data(), {0,0}, {static_cast<int>(p_lay.extent(0)),static_cast<int>(p_lay.extent(1))});
595  Table2D<Real,Order::C> t_lay_tab(t_lay.data(), {0,0}, {static_cast<int>(t_lay.extent(0)),static_cast<int>(t_lay.extent(1))});
596  Table2D<Real,Order::C> z_del_tab(z_del.data(), {0,0}, {static_cast<int>(z_del.extent(0)),static_cast<int>(z_del.extent(1))});
597  Table2D<Real,Order::C> qv_lay_tab(qv_lay.data(), {0,0}, {static_cast<int>(qv_lay.extent(0)),static_cast<int>(qv_lay.extent(1))});
598  Table2D<Real,Order::C> qc_lay_tab(qc_lay.data(), {0,0}, {static_cast<int>(qc_lay.extent(0)),static_cast<int>(qc_lay.extent(1))});
599  Table2D<Real,Order::C> qi_lay_tab(qi_lay.data(), {0,0}, {static_cast<int>(qi_lay.extent(0)),static_cast<int>(qi_lay.extent(1))});
600  Table2D<Real,Order::C> cldfrac_tot_tab(cldfrac_tot.data(), {0,0}, {static_cast<int>(cldfrac_tot.extent(0)),static_cast<int>(cldfrac_tot.extent(1))});
601 
602  Table2D<Real,Order::C> lwp_tab(lwp.data(), {0,0}, {static_cast<int>(lwp.extent(0)),static_cast<int>(lwp.extent(1))});
603  Table2D<Real,Order::C> iwp_tab(iwp.data(), {0,0}, {static_cast<int>(iwp.extent(0)),static_cast<int>(iwp.extent(1))});
604  Table2D<Real,Order::C> eff_radius_qc_tab(eff_radius_qc.data(), {0,0}, {static_cast<int>(eff_radius_qc.extent(0)),static_cast<int>(eff_radius_qc.extent(1))});
605  Table2D<Real,Order::C> eff_radius_qi_tab(eff_radius_qi.data(), {0,0}, {static_cast<int>(eff_radius_qi.extent(0)),static_cast<int>(eff_radius_qi.extent(1))});
606 
607  Table2D<Real,Order::C> p_lev_tab(p_lev.data(), {0,0}, {static_cast<int>(p_lev.extent(0)),static_cast<int>(p_lev.extent(1))});
608  Table2D<Real,Order::C> t_lev_tab(t_lev.data(), {0,0}, {static_cast<int>(t_lev.extent(0)),static_cast<int>(t_lev.extent(1))});
609 
610  Table1D<Real> lat_tab(lat.data(), {0}, {static_cast<int>(lat.extent(0))});
611  Table1D<Real> lon_tab(lon.data(), {0}, {static_cast<int>(lon.extent(0))});
612  Table1D<Real> t_sfc_tab(t_sfc.data(), {0}, {static_cast<int>(t_sfc.extent(0))});
613 
614  bool moist = m_moist;
615  bool ice = m_ice;
616  const int qi_comp = m_qi_comp;
617  const bool has_lsm = m_lsm;
618  const bool has_lat = m_lat;
619  const bool has_lon = m_lon;
620  const bool has_surflayer = (t_surf);
621  int ncol = m_ncol;
622  int nlay = m_nlay;
623  Real dz = m_geom.CellSize(2);
624  Real cons_lat = m_lat_cons;
625  Real cons_lon = m_lon_cons;
626  Real rad_t_sfc = m_rad_t_sfc;
627  Real rdOcp = m_rdOcp;
628 
629  for (MFIter mfi(*m_cons_in); mfi.isValid(); ++mfi) {
630  const auto& vbx = mfi.validbox();
631  const int nx = vbx.length(0);
632  const int imin = vbx.smallEnd(0);
633  const int jmin = vbx.smallEnd(1);
634  const int offset = m_col_offsets[mfi.index()];
635  const Array4<const Real>& cons_arr = m_cons_in->const_array(mfi);
636  const Array4<const Real>& z_arr = (m_z_phys) ? m_z_phys->const_array(mfi) :
637  Array4<const Real>{};
638  const Array4<const Real>& lat_arr = (m_lat) ? m_lat->const_array(mfi) :
639  Array4<const Real>{};
640  const Array4<const Real>& lon_arr = (m_lon) ? m_lon->const_array(mfi) :
641  Array4<const Real>{};
642  ParallelFor(vbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
643  {
644  // map [i,j,k] 0-based to [icol, ilay] 0-based
645  const int icol = (j-jmin)*nx + (i-imin) + offset;
646  const int ilay = k;
647 
648  // EOS input (at CC)
649  Real r = cons_arr(i,j,k,Rho_comp);
650  Real rt = cons_arr(i,j,k,RhoTheta_comp);
651  Real qv = (moist) ? std::max(cons_arr(i,j,k,RhoQ1_comp)/r,Real(0.)) : Real(0.);
652  Real qc = (moist) ? std::max(cons_arr(i,j,k,RhoQ2_comp)/r,Real(0.)) : Real(0.);
653  Real qi = (ice && qi_comp >= 0) ? std::max(cons_arr(i,j,k,qi_comp)/r,Real(0.)) : Real(0.);
654 
655  // EOS avg to z-face
656  Real r_lo = cons_arr(i,j,k-1,Rho_comp);
657  Real rt_lo = cons_arr(i,j,k-1,RhoTheta_comp);
658  Real qv_lo = (moist) ? cons_arr(i,j,k-1,RhoQ1_comp)/r_lo : Real(0.);
659  Real dz_k = (z_arr) ? Real(0.125) * ( (z_arr(i ,j ,k+1) - z_arr(i ,j ,k))
660  + (z_arr(i+1,j ,k+1) - z_arr(i+1,j ,k))
661  + (z_arr(i ,j+1,k+1) - z_arr(i ,j+1,k))
662  + (z_arr(i+1,j+1,k+1) - z_arr(i+1,j+1,k)) ) : Real(0.5)*dz; // Dist from w-face to CC at k
663  Real dz_km1 = (z_arr) ? Real(0.125) * ( (z_arr(i ,j ,k ) - z_arr(i ,j ,k-1))
664  + (z_arr(i+1,j ,k ) - z_arr(i+1,j ,k-1))
665  + (z_arr(i ,j+1,k ) - z_arr(i ,j+1,k-1))
666  + (z_arr(i+1,j+1,k ) - z_arr(i+1,j+1,k-1)) ) : Real(0.5)*dz; // Dist from w-face to CC at k-1
667  // NOTE: Linear interpolation to the w-face weights each CC value by the
668  // distance from the face to the *opposite* CC (inverse distance)
669  Real r_avg = (dz_km1*r + dz_k*r_lo ) / (dz_k + dz_km1);
670  Real rt_avg = (dz_km1*rt + dz_k*rt_lo) / (dz_k + dz_km1);
671  Real qv_avg = (dz_km1*qv + dz_k*qv_lo) / (dz_k + dz_km1);
672 
673  // Views at CC
674  r_lay_tab(icol,ilay) = r;
675 
676  p_lay_tab(icol,ilay) = getPgivenRTh(rt, qv);
677  t_lay_tab(icol,ilay) = getTgivenRandRTh(r, rt, qv);
678  z_del_tab(icol,ilay) = (z_arr) ? Real(0.25) * ( (z_arr(i ,j ,k+1) - z_arr(i ,j ,k))
679  + (z_arr(i+1,j ,k+1) - z_arr(i+1,j ,k))
680  + (z_arr(i ,j+1,k+1) - z_arr(i ,j+1,k))
681  + (z_arr(i+1,j+1,k+1) - z_arr(i+1,j+1,k)) ) : dz;
682  qv_lay_tab(icol,ilay) = qv;
683  qc_lay_tab(icol,ilay) = qc;
684  qi_lay_tab(icol,ilay) = qi;
685  // NOTE: Binary (all-or-nothing) cloud fraction, consistent with saturation adjustment and suited to
686  // resolved clouds; with it erf.rad_do_subcol_sampling has no effect (see #5212)
687  cldfrac_tot_tab(icol,ilay) = ((qc+qi)>Real(0.)) ? Real(1.) : Real(0.);
688 
689  // NOTE: These are populated in 'mixing_ratio_to_cloud_mass'
690  lwp_tab(icol,ilay) = Real(0.);
691  iwp_tab(icol,ilay) = Real(0.);
692 
693  // NOTE: These would be populated from P3 (we use the constants in p3_main_impl.hpp)
694  // NOTE: These are in units of micron!
695  eff_radius_qc_tab(icol,ilay) = (qc>Real(0.)) ? Real(10.0) : Real(0.);
696  eff_radius_qi_tab(icol,ilay) = (qi>Real(0.)) ? Real(25.0) : Real(0.);
697 
698  // Buffers on z-faces (nlay+1)
699  p_lev_tab(icol,ilay) = getPgivenRTh(rt_avg, qv_avg);
700  t_lev_tab(icol,ilay) = getTgivenRandRTh(r_avg, rt_avg, qv_avg);
701  if (ilay==(nlay-1)) {
702  Real r_hi = cons_arr(i,j,k+1,Rho_comp);
703  Real rt_hi = cons_arr(i,j,k+1,RhoTheta_comp);
704  Real qv_hi = (moist) ? std::max(cons_arr(i,j,k+1,RhoQ1_comp)/r_hi,Real(0.)) : Real(0.);
705  Real dz_kp1 = (z_arr) ? Real(0.125) * ( (z_arr(i ,j ,k+2) - z_arr(i ,j ,k+1))
706  + (z_arr(i+1,j ,k+2) - z_arr(i+1,j ,k+1))
707  + (z_arr(i ,j+1,k+2) - z_arr(i ,j+1,k+1))
708  + (z_arr(i+1,j+1,k+2) - z_arr(i+1,j+1,k+1)) ) : Real(0.5)*dz; // Dist from w-face to CC at k+1
709  r_avg = (dz_kp1*r + dz_k*r_hi ) / (dz_k + dz_kp1);
710  rt_avg = (dz_kp1*rt + dz_k*rt_hi) / (dz_k + dz_kp1);
711  qv_avg = (dz_kp1*qv + dz_k*qv_hi) / (dz_k + dz_kp1);
712  p_lev_tab(icol,ilay+1) = getPgivenRTh(rt_avg, qv_avg);
713  t_lev_tab(icol,ilay+1) = getTgivenRandRTh(r_avg, rt_avg, qv_avg);
714  }
715 
716  // 1D data structures
717  if (k==0) {
718  lat_tab(icol) = (has_lat) ? lat_arr(i,j,0) : cons_lat;
719  lon_tab(icol) = (has_lon) ? lon_arr(i,j,0) : cons_lon;
720  }
721 
722  });
723  } // mfi
724 
725  // Populate vars LSM would provide
726  if (!has_lsm && !has_surflayer) {
727  // Parsed surface temp
728  Kokkos::deep_copy(t_sfc, rad_t_sfc);
729 
730  // EAMXX dummy atmos constants
731  Kokkos::deep_copy(sfc_alb_dir_vis, Real(0.06));
732  Kokkos::deep_copy(sfc_alb_dir_nir, Real(0.06));
733  Kokkos::deep_copy(sfc_alb_dif_vis, Real(0.06));
734  Kokkos::deep_copy(sfc_alb_dif_nir, Real(0.06));
735 
736  // AML NOTE: These are not used in current EAMXX, I've left
737  // the code to plug into these if we need it.
738  //
739  // Current EAMXX constants
740  Kokkos::deep_copy(sfc_emis, Real(0.98));
741  Kokkos::deep_copy(lw_src , zero );
742  } else {
743  Vector<real1d_k> rrtmgp_in_vars = {t_sfc, sfc_emis,
746  Vector<Real> rrtmgp_default_vals = {rad_t_sfc, Real(0.98),
747  Real(0.06), Real(0.06),
748  Real(0.06), Real(0.06)};
749  for (int ivar(0); ivar<lsm_input_ptrs.size(); ivar++) {
750  auto rrtmgp_default_val = rrtmgp_default_vals[ivar];
751  auto rrtmgp_to_fill_k = rrtmgp_in_vars[ivar];
752  amrex::Table1D<amrex::Real> rrtmgp_to_fill(rrtmgp_to_fill_k.data(),
753  0, rrtmgp_to_fill_k.extent(0));
754  for (MFIter mfi(*m_cons_in); mfi.isValid(); ++mfi) {
755  const auto& vbx = mfi.validbox();
756  const auto& sbx = makeSlab(vbx,2,vbx.smallEnd(2));
757  const int nx = vbx.length(0);
758  const int imin = vbx.smallEnd(0);
759  const int jmin = vbx.smallEnd(1);
760  const int offset = m_col_offsets[mfi.index()];
761  const int k_surface = vbx.smallEnd(2);
762  const Array4<const Real>& cons_arr = m_cons_in->const_array(mfi);
763  const Array4<const Real>& z_arr = (m_z_phys) ? m_z_phys->const_array(mfi) :
764  Array4<const Real>{};
765  const Array4<const Real>& zsfc_arr = (m_z_phys) ? m_z_sfc->const_array(mfi) :
766  Array4<const Real>{};
767  const Array4<const int>& lmask_arr = (lmask) ? lmask->const_array(mfi) :
768  Array4<const int> {};
769  const Array4<const Real>& tsurf_arr = (t_surf) ? t_surf->const_array(mfi) :
770  Array4<const Real> {};
771  const Array4<const Real>& lsm_in_arr = (lsm_input_ptrs[ivar]) ? lsm_input_ptrs[ivar]->const_array(mfi) :
772  Array4<const Real> {};
773  ParallelFor(sbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
774  {
775  // map [i,j,k] 0-based to [icol, ilay] 0-based
776  const int icol = (j-jmin)*nx + (i-imin) + offset;
777 
778  // Check if over land
779  bool is_land = (lmask_arr) ? lmask_arr(i,j,k) : 1;
780 
781  // Surface temperature has a distinct contract: LSM and
782  // RRTMGP use absolute temperature, while SurfaceLayer
783  // supplies potential temperature. The other LSM inputs
784  // retain their existing validity/default handling.
785  if (ivar == 0) {
786  const bool has_lsm_t_sfc = static_cast<bool>(lsm_in_arr);
787  const bool valid_lsm_t_sfc =
788  has_lsm_t_sfc && amrex::Math::isfinite(lsm_in_arr(i,j,k)) &&
789  (lsm_in_arr(i,j,k) > Real(0.)) &&
790  (lsm_in_arr(i,j,k) < lsm_undefined);
791  // Match TwoStream: convert SurfaceLayer theta with
792  // the physical surface pressure diagnosed from the
793  // lowest atmospheric cell.
795  is_land,
796  has_lsm_t_sfc,
797  valid_lsm_t_sfc,
798  has_lsm_t_sfc ? lsm_in_arr(i,j,k) : Real(0.),
799  static_cast<bool>(tsurf_arr),
800  tsurf_arr ? tsurf_arr(i,j,k) : Real(0.),
802  cons_arr(i,j,k_surface,Rho_comp),
803  cons_arr(i,j,k_surface,RhoTheta_comp),
804  moist ? std::max(cons_arr(i,j,k_surface,RhoQ1_comp) /
805  cons_arr(i,j,k_surface,Rho_comp), Real(0.)) : Real(0.),
806  z_arr ? Compute_Zrel_AtCellCenter(i,j,k_surface,zsfc_arr,z_arr) : Real(0.5)*dz),
807  rdOcp,
808  rrtmgp_default_val,
809  rrtmgp_to_fill(icol));
810  } else {
811  // Have LSM and are over land.
812  const bool valid_lsm_data =
813  (lsm_in_arr && (lsm_in_arr(i,j,k) < lsm_undefined));
814  if (is_land && valid_lsm_data) {
815  rrtmgp_to_fill(icol) = lsm_in_arr(i,j,k);
816  } else {
817  // Use the default value.
818  rrtmgp_to_fill(icol) = rrtmgp_default_val;
819  }
820  }
821  });
822  } //mfi
823  } // ivar
824  Kokkos::deep_copy(lw_src, zero );
825  } // have lsm
826 
827  // Enforce consistency between t_sfc and t_lev at bottom surface
828  Kokkos::parallel_for(Kokkos::RangePolicy(0, ncol),
829  KOKKOS_LAMBDA (int icol)
830  {
831  t_lev_tab(icol,0) = t_sfc_tab(icol);
832  });
833 }
constexpr amrex::Real lsm_undefined
Definition: ERF_Constants.H:28
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:81
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:79
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_Zrel_AtCellCenter(const int &i, const int &j, const int &k, const amrex::Array4< const amrex::Real > &z_sfc_nd, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:764
amrex::MultiFab * m_lon
Definition: ERF_Radiation.H:348
amrex::MultiFab * m_z_phys
Definition: ERF_Radiation.H:341
amrex::MultiFab * m_z_sfc
Definition: ERF_Radiation.H:344
amrex::Geometry m_geom
Definition: ERF_Radiation.H:297
amrex::MultiFab * m_lat
Definition: ERF_Radiation.H:347
@ qv
Definition: ERF_Kessler.H:31
@ qi
Definition: ERF_Morrison.H:111
@ qc
Definition: ERF_Morrison.H:110
@ dz
Definition: ERF_AdvanceWDM6.cpp:273
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pressure_at_surface(const amrex::Real rho, const amrex::Real rho_theta, const amrex::Real qv, const amrex::Real delta_z)
Definition: ERF_SurfaceTemperature.H:112
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void resolve_surface_temperature(const bool is_land, const bool has_lsm_t_sfc, const bool valid_lsm_t_sfc, const amrex::Real lsm_t_sfc, const bool has_surface_layer, const amrex::Real surface_layer_theta, const amrex::Real surface_pressure, const amrex::Real rdOcp, const amrex::Real default_t_sfc, amrex::Real &t_sfc)
Definition: ERF_RRTMGP_SurfaceTemperature.H:39
Here is the call graph for this function:

◆ nDatalogBdyComp()

int Radiation::nDatalogBdyComp ( ) const
inlineprivate
387 { return bdyZtopComp(nDatalogFluxComp()) + 1; }
int nDatalogFluxComp() const
Definition: ERF_Radiation.H:372
static constexpr AMREX_GPU_HOST_DEVICE int bdyZtopComp(int nflux)
Definition: ERF_Radiation.H:385
Here is the call graph for this function:

◆ nDatalogComp()

int Radiation::nDatalogComp ( ) const
inlineprivate
379 { return n_datalog_nonflux + nDatalogFluxComp(); }
static constexpr int n_datalog_nonflux
Definition: ERF_Radiation.H:369
Here is the call graph for this function:

◆ nDatalogFluxComp()

int Radiation::nDatalogFluxComp ( ) const
inlineprivate
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  }
static constexpr int n_flux_sets_base
Definition: ERF_Radiation.H:364
static constexpr int n_flux_per_set
Definition: ERF_Radiation.H:363

Referenced by nDatalogBdyComp(), and nDatalogComp().

Here is the caller graph for this function:

◆ populateDatalogMF()

void Radiation::populateDatalogMF ( )
978 {
979  Table2D<Real,Order::C> sw_flux_up_tab(sw_flux_up.data(), {0,0}, {static_cast<int>(sw_flux_up.extent(0)),static_cast<int>(sw_flux_up.extent(1))});
980  Table2D<Real,Order::C> sw_flux_dn_tab(sw_flux_dn.data(), {0,0}, {static_cast<int>(sw_flux_dn.extent(0)),static_cast<int>(sw_flux_dn.extent(1))});
981  Table2D<Real,Order::C> sw_flux_dn_dir_tab(sw_flux_dn_dir.data(), {0,0}, {static_cast<int>(sw_flux_dn_dir.extent(0)),static_cast<int>(sw_flux_dn_dir.extent(1))});
982  Table2D<Real,Order::C> lw_flux_up_tab(lw_flux_up.data(), {0,0}, {static_cast<int>(lw_flux_up.extent(0)),static_cast<int>(lw_flux_up.extent(1))});
983  Table2D<Real,Order::C> lw_flux_dn_tab(lw_flux_dn.data(), {0,0}, {static_cast<int>(lw_flux_dn.extent(0)),static_cast<int>(lw_flux_dn.extent(1))});
984 
985  Table2D<Real,Order::C> sw_clrsky_flux_up_tab(sw_clrsky_flux_up.data(), {0,0},
986  {static_cast<int>(sw_clrsky_flux_up.extent(0)),static_cast<int>(sw_clrsky_flux_up.extent(1))});
987  Table2D<Real,Order::C> sw_clrsky_flux_dn_tab(sw_clrsky_flux_dn.data(), {0,0},
988  {static_cast<int>(sw_clrsky_flux_dn.extent(0)),static_cast<int>(sw_clrsky_flux_dn.extent(1))});
989  Table2D<Real,Order::C> sw_clrsky_flux_dn_dir_tab(sw_clrsky_flux_dn_dir.data(), {0,0},
990  {static_cast<int>(sw_clrsky_flux_dn_dir.extent(0)),static_cast<int>(sw_clrsky_flux_dn_dir.extent(1))});
991  Table2D<Real,Order::C> lw_clrsky_flux_up_tab(lw_clrsky_flux_up.data(), {0,0},
992  {static_cast<int>(lw_clrsky_flux_up.extent(0)),static_cast<int>(lw_clrsky_flux_up.extent(1))});
993  Table2D<Real,Order::C> lw_clrsky_flux_dn_tab(lw_clrsky_flux_dn.data(), {0,0},
994  {static_cast<int>(lw_clrsky_flux_dn.extent(0)),static_cast<int>(lw_clrsky_flux_dn.extent(1))});
995  Table2D<Real,Order::C> sw_clrsky_heating_tab(sw_clrsky_heating.data(), {0,0},
996  {static_cast<int>(sw_clrsky_heating.extent(0)),static_cast<int>(sw_clrsky_heating.extent(1))});
997  Table2D<Real,Order::C> lw_clrsky_heating_tab(lw_clrsky_heating.data(), {0,0},
998  {static_cast<int>(lw_clrsky_heating.extent(0)),static_cast<int>(lw_clrsky_heating.extent(1))});
999  Table2D<Real,Order::C> sw_clnsky_flux_up_tab(sw_clnsky_flux_up.data(), {0,0},
1000  {static_cast<int>(sw_clnsky_flux_up.extent(0)),static_cast<int>(sw_clnsky_flux_up.extent(1))});
1001  Table2D<Real,Order::C> sw_clnsky_flux_dn_tab(sw_clnsky_flux_dn.data(), {0,0},
1002  {static_cast<int>(sw_clnsky_flux_dn.extent(0)),static_cast<int>(sw_clnsky_flux_dn.extent(1))});
1003  Table2D<Real,Order::C> sw_clnsky_flux_dn_dir_tab(sw_clnsky_flux_dn_dir.data(), {0,0},
1004  {static_cast<int>(sw_clnsky_flux_dn_dir.extent(0)),static_cast<int>(sw_clnsky_flux_dn_dir.extent(1))});
1005  Table2D<Real,Order::C> lw_clnsky_flux_up_tab(lw_clnsky_flux_up.data(), {0,0},
1006  {static_cast<int>(lw_clnsky_flux_up.extent(0)),static_cast<int>(lw_clnsky_flux_up.extent(1))});
1007  Table2D<Real,Order::C> lw_clnsky_flux_dn_tab(lw_clnsky_flux_dn.data(), {0,0},
1008  {static_cast<int>(lw_clnsky_flux_dn.extent(0)),static_cast<int>(lw_clnsky_flux_dn.extent(1))});
1009  Table2D<Real,Order::C> sw_clnclrsky_flux_up_tab(sw_clnclrsky_flux_up.data(), {0,0},
1010  {static_cast<int>(sw_clnclrsky_flux_up.extent(0)),static_cast<int>(sw_clnclrsky_flux_up.extent(1))});
1011  Table2D<Real,Order::C> sw_clnclrsky_flux_dn_tab(sw_clnclrsky_flux_dn.data(), {0,0},
1012  {static_cast<int>(sw_clnclrsky_flux_dn.extent(0)),static_cast<int>(sw_clnclrsky_flux_dn.extent(1))});
1013  Table2D<Real,Order::C> sw_clnclrsky_flux_dn_dir_tab(sw_clnclrsky_flux_dn_dir.data(), {0,0},
1014  {static_cast<int>(sw_clnclrsky_flux_dn_dir.extent(0)),static_cast<int>(sw_clnclrsky_flux_dn_dir.extent(1))});
1015  Table2D<Real,Order::C> lw_clnclrsky_flux_up_tab(lw_clnclrsky_flux_up.data(), {0,0},
1016  {static_cast<int>(lw_clnclrsky_flux_up.extent(0)),static_cast<int>(lw_clnclrsky_flux_up.extent(1))});
1017  Table2D<Real,Order::C> lw_clnclrsky_flux_dn_tab(lw_clnclrsky_flux_dn.data(), {0,0},
1018  {static_cast<int>(lw_clnclrsky_flux_dn.extent(0)),static_cast<int>(lw_clnclrsky_flux_dn.extent(1))});
1019 
1020  Table1D<Real> mu0_tab(mu0.data(), {0}, {static_cast<int>(mu0.extent(0))});
1021 
1022  // Layer pressure, to convert the clear-sky heating rates to potential temperature tendencies
1023  Table2D<Real,Order::C> p_lay_tab(p_lay.data(), {0,0}, {static_cast<int>(p_lay.extent(0)),static_cast<int>(p_lay.extent(1))});
1024  const Real rdOcp = m_rdOcp;
1025 
1026  auto extra_clnsky_diag = m_extra_clnsky_diag;
1027  auto extra_clnclrsky_diag = m_extra_clnclrsky_diag;
1028 
1029  Real dz = m_geom.CellSize(2);
1030  const int ktop = m_geom.Domain().bigEnd(2);
1031 
1032  // Local copies of the layout constants for the kernel. The per-cell flux arrays are sized
1033  // by max_datalog_flux, so the enabled flux count must fit in them.
1034  constexpr int max_flux = max_datalog_flux;
1035  constexpr int nset = n_flux_per_set;
1037  "RRTMGP datalog flux count exceeds max_datalog_flux");
1038 
1039  // Every write goes through a guard, so a count that does not match the allocation never
1040  // indexes past the end; it raises this flag instead, which the host checks after the loop
1041  // since device-side asserts are compiled out of release GPU builds
1042  const int ncomp = datalog_mf.nComp();
1043  const int nflux = nDatalogFluxComp();
1044  Gpu::Buffer<int> d_err({0});
1045  int* err = d_err.data();
1046 
1047  for (MFIter mfi(datalog_mf); mfi.isValid(); ++mfi) {
1048  const auto& vbx = mfi.validbox();
1049  const int nx = vbx.length(0);
1050  const int imin = vbx.smallEnd(0);
1051  const int jmin = vbx.smallEnd(1);
1052  const int offset = m_col_offsets[mfi.index()];
1053  const Array4<Real>& dst_arr = datalog_mf.array(mfi);
1054  const Array4<Real>& bdy_arr = datalog_bdy_mf.array(mfi);
1055  const Array4<Real>& q_arr = m_qheating_rates->array(mfi);
1056  // Heights above ground need both the node heights and the surface heights
1057  const bool has_z = (m_z_phys != nullptr) && (m_z_sfc != nullptr);
1058  const Array4<const Real>& z_arr = (has_z) ? m_z_phys->const_array(mfi) :
1059  Array4<const Real>{};
1060  const Array4<const Real>& zsfc_arr = (has_z) ? m_z_sfc->const_array(mfi) :
1061  Array4<const Real>{};
1062 
1063  ParallelFor(vbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
1064  {
1065  // map [i,j,k] 0-based to [icol, ilay] 0-based
1066  const int icol = (j-jmin)*nx + (i-imin) + offset;
1067  const int ilay = k;
1068 
1069  // Fluxes on the lower (flo) and upper (fhi) faces of this layer, in datalog order:
1070  // all-sky, clear-sky, then the optional clean-sky and clean-clear-sky sets
1071  Real flo[max_flux];
1072  Real fhi[max_flux];
1073  int nf = 0;
1074  auto add_flux = [&] (const Table2D<Real,Order::C>& tab)
1075  {
1076  if (nf < max_flux) {
1077  flo[nf] = tab(icol,ilay);
1078  fhi[nf] = tab(icol,ilay+1);
1079  }
1080  ++nf;
1081  };
1082 
1083  add_flux(sw_flux_up_tab);
1084  add_flux(sw_flux_dn_tab);
1085  add_flux(sw_flux_dn_dir_tab);
1086  add_flux(lw_flux_up_tab);
1087  add_flux(lw_flux_dn_tab);
1088 
1089  add_flux(sw_clrsky_flux_up_tab);
1090  add_flux(sw_clrsky_flux_dn_tab);
1091  add_flux(sw_clrsky_flux_dn_dir_tab);
1092  add_flux(lw_clrsky_flux_up_tab);
1093  add_flux(lw_clrsky_flux_dn_tab);
1094 
1095  if (extra_clnsky_diag) {
1096  add_flux(sw_clnsky_flux_up_tab);
1097  add_flux(sw_clnsky_flux_dn_tab);
1098  add_flux(sw_clnsky_flux_dn_dir_tab);
1099  add_flux(lw_clnsky_flux_up_tab);
1100  add_flux(lw_clnsky_flux_dn_tab);
1101  }
1102 
1103  if (extra_clnclrsky_diag) {
1104  add_flux(sw_clnclrsky_flux_up_tab);
1105  add_flux(sw_clnclrsky_flux_dn_tab);
1106  add_flux(sw_clnclrsky_flux_dn_dir_tab);
1107  add_flux(lw_clnclrsky_flux_up_tab);
1108  add_flux(lw_clnclrsky_flux_dn_tab);
1109  }
1110 
1111  const int nf_set = amrex::min(nf, nflux);
1112 
1113  int idx = 0;
1114  auto put = [&] (Real val)
1115  {
1116  if (idx < ncomp) { dst_arr(i,j,k,idx) = val; }
1117  ++idx;
1118  };
1119 
1120  // Height above ground level at cell center
1121  put( (z_arr) ? Compute_Zrel_AtCellCenter(i,j,k,zsfc_arr,z_arr) : (k + myhalf)*dz );
1122 
1123  // Heating rates
1124  put( q_arr(i, j, k, 0) );
1125  put( q_arr(i, j, k, 1) );
1126 
1127  // All-sky fluxes, averaged from the faces to the cell center
1128  for (int n = 0; n < nset && n < nf_set; ++n) { put( myhalf * (flo[n] + fhi[n]) ); }
1129 
1130  // Cosine zenith angle
1131  put( mu0_tab(icol) );
1132 
1133  // Clear sky heating rates, converted from dT/dt to dTheta/dt to match the
1134  // all-sky rates, which kokkos_buffers_to_mf() has already converted
1135  const Real iexner = rrtmgp::inverse_exner(Real(p_lay_tab(icol,ilay)), rdOcp);
1136  put( sw_clrsky_heating_tab(icol, ilay) * iexner );
1137  put( lw_clrsky_heating_tab(icol, ilay) * iexner );
1138 
1139  // Clear, clean and clean-clear sky fluxes, averaged to the cell center
1140  for (int n = nset; n < nf_set; ++n) { put( myhalf * (flo[n] + fhi[n]) ); }
1141 
1142  // Fluxes on the surface and top-of-atmosphere faces, and the top-face height
1143  if (k == 0) {
1144  for (int n = 0; n < nf_set; ++n) { bdy_arr(i,j,0,bdySfcComp(n)) = flo[n]; }
1145  }
1146  if (k == ktop) {
1147  for (int n = 0; n < nf_set; ++n) { bdy_arr(i,j,0,bdyToaComp(n,nflux)) = fhi[n]; }
1148  bdy_arr(i,j,0,bdyZtopComp(nflux)) = (z_arr) ?
1149  fourth*( z_arr(i,j,k+1) + z_arr(i+1,j,k+1) + z_arr(i,j+1,k+1) + z_arr(i+1,j+1,k+1) )
1150  - fourth*( zsfc_arr(i,j,0) + zsfc_arr(i+1,j,0) + zsfc_arr(i,j+1,0) + zsfc_arr(i+1,j+1,0) )
1151  : (k + 1)*dz;
1152  }
1153 
1154  // The write counts must match the components allocated in set_grids
1155  if (idx != ncomp || nf != nflux) { *err = 1; }
1156  });
1157  }
1158 
1159  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(*(d_err.copyToHost()) == 0,
1160  "RRTMGP datalog write count does not match the datalog allocation");
1161 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int idx(int i, int j, int k, int nx, int ny)
Definition: ERF_InitForEnsemble.cpp:404
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
amrex::MultiFab datalog_mf
Definition: ERF_Radiation.H:356
amrex::MultiFab datalog_bdy_mf
Definition: ERF_Radiation.H:357
static constexpr int max_datalog_flux
Definition: ERF_Radiation.H:366
static constexpr AMREX_GPU_HOST_DEVICE int bdyToaComp(int n, int nflux)
Definition: ERF_Radiation.H:384
static constexpr AMREX_GPU_HOST_DEVICE int bdySfcComp(int n)
Definition: ERF_Radiation.H:383
Here is the call graph for this function:

◆ rad_run_impl()

void Radiation::rad_run_impl ( const amrex::Vector< amrex::MultiFab * > &  lsm_output_ptrs)
inline
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  }
void initialize_impl()
Definition: ERF_Radiation.cpp:1292
void run_impl()
Definition: ERF_Radiation.cpp:1317
int m_orbital_mon
Definition: ERF_Radiation.H:449
int m_orbital_sec
Definition: ERF_Radiation.H:451
bool m_update_rad
Definition: ERF_Radiation.H:303
int m_orbital_day
Definition: ERF_Radiation.H:450
void finalize_impl(const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
Definition: ERF_Radiation.cpp:1615

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ radiation_updated()

bool Radiation::radiation_updated ( ) const
inlineoverridevirtual

Reports whether the last radiation call updated its outputs.

Returns
True when the radiation kernel wrote output fields.

Reimplemented from IRadiation.

181 { return m_update_rad && !m_is_nested_patch; }

◆ Run()

virtual void Radiation::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 
)
inlineoverridevirtual

Implements IRadiation.

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  }
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
void rad_run_impl(const amrex::Vector< amrex::MultiFab * > &lsm_output_ptrs)
Definition: ERF_Radiation.H:239
amrex::Real m_declin
Definition: ERF_Radiation.H:471
amrex::Real m_calday
Definition: ERF_Radiation.H:472
Here is the call graph for this function:

◆ run_impl()

void Radiation::run_impl ( )
1318 {
1319  // A rank that owns no boxes on this level has no columns and therefore no
1320  // radiation work to do. Bail out before the chunk loop; there are no MPI
1321  // collectives in this routine, so returning early cannot deadlock.
1322  if (m_ncol == 0) { return; }
1323 
1324  // Local copies
1325  const auto ncol = m_ncol;
1326  const auto nlay = m_nlay;
1327  const auto nswbands = m_nswbands;
1328 
1329  // Compute orbital parameters; these are used both for computing
1330  // the solar zenith angle and also for computing total solar
1331  // irradiance scaling (tsi_scaling).
1332  double obliqr, lambm0, mvelpp;
1333  // Any of eccen/obliq/mvelp that the user set (i.e. is non-negative) is used
1334  // as is by orbital_params; the rest are computed from the orbital year.
1335  int orbital_year = m_orbital_year;
1336  double eccen = m_orbital_eccen;
1337  double obliq = m_orbital_obliq;
1338  double mvelp = m_orbital_mvelp;
1339  orbital_params(orbital_year, eccen, obliq,
1340  mvelp, obliqr, lambm0, mvelpp);
1341 
1342  // Use the orbital parameters to calculate the solar declination and eccentricity factor
1343  double delta, eccf;
1344  // Day of the year plus fraction, calday 1 == Jan 1 0Z (leap-aware)
1346  orbital_decl(calday, eccen, mvelpp, lambm0, obliqr, delta, eccf);
1347  m_calday = calday;
1348  m_declin = delta;
1349 
1350  // Overwrite eccf if using a fixed solar constant.
1351  auto fixed_total_solar_irradiance = m_fixed_total_solar_irradiance;
1352  if (fixed_total_solar_irradiance >= 0){
1353  eccf = fixed_total_solar_irradiance/Real(1360.9);
1354  }
1355 
1356  // Precompute volume mixing ratio (VMR) for all gases
1357  //
1358  // H2O is obtained from qv.
1359  // O3 may be a constant or a 1D vector
1360  // All other comps are set to constants for now
1361  Vector<real2d_k> vmr_full_vec(m_ngas);
1362  for (int igas(0); igas < m_ngas; ++igas) {
1363  auto name = m_gas_names[igas];
1364  vmr_full_vec[igas] = real2d_k("vmr_full_" + name, ncol, nlay);
1365  auto tmp2d = vmr_full_vec[igas];
1366  auto gas_mol_weight = m_mol_weight_gas[igas];
1367  if (name == "H2O") {
1368  auto qv_lay_d = qv_lay;
1369  Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>>({0, 0}, {ncol, nlay}),
1370  KOKKOS_LAMBDA (int icol, int ilay)
1371  {
1372  tmp2d(icol,ilay) = qv_lay_d(icol,ilay) * mwdair/gas_mol_weight;
1373  });
1374  } else if (name == "CO2") {
1375  Kokkos::deep_copy(tmp2d, m_co2vmr);
1376  } else if (name == "O3") {
1377  if (m_o3_size==1) {
1378  Kokkos::deep_copy(tmp2d, m_o3vmr[0] );
1379  } else {
1380  auto o3_lay_d = o3_lay;
1381  Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>>({0, 0}, {ncol, nlay}),
1382  KOKKOS_LAMBDA (int icol, int ilay)
1383  {
1384  tmp2d(icol,ilay) = o3_lay_d(ilay);
1385  });
1386  }
1387  } else if (name == "N2O") {
1388  Kokkos::deep_copy(tmp2d, m_n2ovmr);
1389  } else if (name == "CO") {
1390  Kokkos::deep_copy(tmp2d, m_covmr );
1391  } else if (name == "CH4") {
1392  Kokkos::deep_copy(tmp2d, m_ch4vmr);
1393  } else if (name == "O2") {
1394  Kokkos::deep_copy(tmp2d, m_o2vmr );
1395  } else if (name == "N2") {
1396  Kokkos::deep_copy(tmp2d, m_n2vmr );
1397  } else {
1398  Abort("Radiation: Unknown gas component.");
1399  }
1400  }
1401 
1402  // Determine the cosine zenith angle.
1403  // Populate mu0 1D array
1404  // This must be done on HOST and copied to device.
1405  auto h_mu0 = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), mu0);
1406  if (m_fixed_solar_zenith_angle > 0) {
1407  Kokkos::deep_copy(h_mu0, m_fixed_solar_zenith_angle);
1408  } else {
1409  auto h_lat = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), lat);
1410  auto h_lon = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), lon);
1411  double dt = double(m_dt);
1412  auto rad_freq_in_steps = m_rad_freq_in_steps;
1413  Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::Serial>(0, ncol),
1414  [&,PI_d=PI] (int icol)
1415  {
1416  // Convert lat/lon to radians
1417  double lat_col = h_lat(icol)*PI_d/Real(180.0);
1418  double lon_col = h_lon(icol)*PI_d/Real(180.0);
1419  double lcalday = calday;
1420  double ldelta = delta;
1421  double dt_avg = static_cast<double>(rad_freq_in_steps) * dt;
1422  h_mu0(icol) = Real(orbital_cos_zenith(lcalday, lat_col, lon_col, ldelta, dt_avg));
1423  });
1424  }
1425  Kokkos::deep_copy(mu0, h_mu0);
1426 
1427  // Compute layer cloud mass per unit area (populates lwp/iwp)
1430 
1431  // Convert to g/m2 (needed by RRTMGP)
1432  Table2D<Real,Order::C> lwp_tab(lwp.data(), {0,0}, {static_cast<int>(lwp.extent(0)),static_cast<int>(lwp.extent(1))});
1433  Table2D<Real,Order::C> iwp_tab(iwp.data(), {0,0}, {static_cast<int>(iwp.extent(0)),static_cast<int>(iwp.extent(1))});
1434  Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>>({0, 0}, {ncol, nlay}),
1435  KOKKOS_LAMBDA (int icol, int ilay)
1436  {
1437  lwp_tab(icol,ilay) *= Real(1.e3);
1438  iwp_tab(icol,ilay) *= Real(1.e3);
1439  });
1440 
1441  // -----------------------------------------------------------------------
1442  // Process radiation in column chunks to limit peak GPU memory.
1443  // Radiation columns are independent (no horizontal coupling), so
1444  // chunking produces bit-identical results.
1445  // -----------------------------------------------------------------------
1446  const int ncol_chunk = std::min(m_ncol_chunk, ncol);
1447  const int kbot = 0;
1448 
1449  for (int col_s = 0; col_s < ncol; col_s += ncol_chunk) {
1450  const int ncol_c = std::min(ncol_chunk, ncol - col_s);
1451 
1452  // --- Chunk subviews: 1D (ncol) ---
1453  real1d_k mu0_c (mu0.data() + col_s, ncol_c);
1454  real1d_k sfc_alb_dir_vis_c (sfc_alb_dir_vis.data() + col_s, ncol_c);
1455  real1d_k sfc_alb_dir_nir_c (sfc_alb_dir_nir.data() + col_s, ncol_c);
1456  real1d_k sfc_alb_dif_vis_c (sfc_alb_dif_vis.data() + col_s, ncol_c);
1457  real1d_k sfc_alb_dif_nir_c (sfc_alb_dif_nir.data() + col_s, ncol_c);
1458  real1d_k sfc_flux_dir_vis_c (sfc_flux_dir_vis.data() + col_s, ncol_c);
1459  real1d_k sfc_flux_dir_nir_c (sfc_flux_dir_nir.data() + col_s, ncol_c);
1460  real1d_k sfc_flux_dif_vis_c (sfc_flux_dif_vis.data() + col_s, ncol_c);
1461  real1d_k sfc_flux_dif_nir_c (sfc_flux_dif_nir.data() + col_s, ncol_c);
1462  real1d_k t_sfc_c (t_sfc.data() + col_s, ncol_c);
1463  real1d_k sfc_emis_c (sfc_emis.data() + col_s, ncol_c);
1464  real1d_k lw_src_c (lw_src.data() + col_s, ncol_c);
1465 
1466  // --- Chunk subviews: 2D (ncol, nlay) via LayoutRight pointer offset ---
1467  const int stride2_nlay = nlay;
1468  const int stride2_nlayp1 = nlay + 1;
1469  real2d_k p_lay_c (p_lay.data() + col_s*stride2_nlay, ncol_c, nlay);
1470  real2d_k t_lay_c (t_lay.data() + col_s*stride2_nlay, ncol_c, nlay);
1471  real2d_k r_lay_c (r_lay.data() + col_s*stride2_nlay, ncol_c, nlay);
1472  real2d_k z_del_c (z_del.data() + col_s*stride2_nlay, ncol_c, nlay);
1473  real2d_k lwp_c (lwp.data() + col_s*stride2_nlay, ncol_c, nlay);
1474  real2d_k iwp_c (iwp.data() + col_s*stride2_nlay, ncol_c, nlay);
1475  real2d_k eff_radius_qc_c(eff_radius_qc.data() + col_s*stride2_nlay, ncol_c, nlay);
1476  real2d_k eff_radius_qi_c(eff_radius_qi.data() + col_s*stride2_nlay, ncol_c, nlay);
1477  real2d_k cldfrac_tot_c (cldfrac_tot.data() + col_s*stride2_nlay, ncol_c, nlay);
1478  real2d_k sw_heating_c (sw_heating.data() + col_s*stride2_nlay, ncol_c, nlay);
1479  real2d_k lw_heating_c (lw_heating.data() + col_s*stride2_nlay, ncol_c, nlay);
1480 
1481  // --- Chunk subviews: 2D (ncol, nlay+1) ---
1482  real2d_k p_lev_c (p_lev.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1483  real2d_k t_lev_c (t_lev.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1484  real2d_k sw_flux_up_c (sw_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1485  real2d_k sw_flux_dn_c (sw_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1486  real2d_k sw_flux_dn_dir_c (sw_flux_dn_dir.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1487  real2d_k lw_flux_up_c (lw_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1488  real2d_k lw_flux_dn_c (lw_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1489  // Clear-sky flux subviews (always active)
1490  // NOTE: once on m_ncol_chunk if not writing a datalog
1491  real2d_k sw_clrsky_flux_up_c, sw_clrsky_flux_dn_c, sw_clrsky_flux_dn_dir_c;
1492  real2d_k lw_clrsky_flux_up_c, lw_clrsky_flux_dn_c;
1493  if (datalog_int > 0) {
1494  sw_clrsky_flux_up_c = real2d_k(sw_clrsky_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1495  sw_clrsky_flux_dn_c = real2d_k(sw_clrsky_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1496  sw_clrsky_flux_dn_dir_c = real2d_k(sw_clrsky_flux_dn_dir.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1497  lw_clrsky_flux_up_c = real2d_k(lw_clrsky_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1498  lw_clrsky_flux_dn_c = real2d_k(lw_clrsky_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1499  } else {
1500  sw_clrsky_flux_up_c = real2d_k(sw_clrsky_flux_up.data() , ncol_c, nlay+1);
1501  sw_clrsky_flux_dn_c = real2d_k(sw_clrsky_flux_dn.data() , ncol_c, nlay+1);
1502  sw_clrsky_flux_dn_dir_c = real2d_k(sw_clrsky_flux_dn_dir.data() , ncol_c, nlay+1);
1503  lw_clrsky_flux_up_c = real2d_k(lw_clrsky_flux_up.data() , ncol_c, nlay+1);
1504  lw_clrsky_flux_dn_c = real2d_k(lw_clrsky_flux_dn.data() , ncol_c, nlay+1);
1505  }
1506 
1507  // Diagnostic flux subviews (placeholder when disabled)
1508  real2d_k sw_clnclrsky_flux_up_c, sw_clnclrsky_flux_dn_c, sw_clnclrsky_flux_dn_dir_c;
1509  real2d_k lw_clnclrsky_flux_up_c, lw_clnclrsky_flux_dn_c;
1510  if (m_extra_clnclrsky_diag) {
1511  sw_clnclrsky_flux_up_c = real2d_k(sw_clnclrsky_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1512  sw_clnclrsky_flux_dn_c = real2d_k(sw_clnclrsky_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1513  sw_clnclrsky_flux_dn_dir_c = real2d_k(sw_clnclrsky_flux_dn_dir.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1514  lw_clnclrsky_flux_up_c = real2d_k(lw_clnclrsky_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1515  lw_clnclrsky_flux_dn_c = real2d_k(lw_clnclrsky_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1516  } else {
1517  sw_clnclrsky_flux_up_c = real2d_k("sw_clnclrsky_flux_up_c" , 1, 1);
1518  sw_clnclrsky_flux_dn_c = real2d_k("sw_clnclrsky_flux_dn_c" , 1, 1);
1519  sw_clnclrsky_flux_dn_dir_c = real2d_k("sw_clnclrsky_flux_dn_dir_c", 1, 1);
1520  lw_clnclrsky_flux_up_c = real2d_k("lw_clnclrsky_flux_up_c" , 1, 1);
1521  lw_clnclrsky_flux_dn_c = real2d_k("lw_clnclrsky_flux_dn_c" , 1, 1);
1522  }
1523 
1524  real2d_k sw_clnsky_flux_up_c, sw_clnsky_flux_dn_c, sw_clnsky_flux_dn_dir_c;
1525  real2d_k lw_clnsky_flux_up_c, lw_clnsky_flux_dn_c;
1526  if (m_extra_clnsky_diag) {
1527  sw_clnsky_flux_up_c = real2d_k(sw_clnsky_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1528  sw_clnsky_flux_dn_c = real2d_k(sw_clnsky_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1529  sw_clnsky_flux_dn_dir_c = real2d_k(sw_clnsky_flux_dn_dir.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1530  lw_clnsky_flux_up_c = real2d_k(lw_clnsky_flux_up.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1531  lw_clnsky_flux_dn_c = real2d_k(lw_clnsky_flux_dn.data() + col_s*stride2_nlayp1, ncol_c, nlay+1);
1532  } else {
1533  sw_clnsky_flux_up_c = real2d_k("sw_clnsky_flux_up_c" , 1, 1);
1534  sw_clnsky_flux_dn_c = real2d_k("sw_clnsky_flux_dn_c" , 1, 1);
1535  sw_clnsky_flux_dn_dir_c = real2d_k("sw_clnsky_flux_dn_dir_c", 1, 1);
1536  lw_clnsky_flux_up_c = real2d_k("lw_clnsky_flux_up_c" , 1, 1);
1537  lw_clnsky_flux_dn_c = real2d_k("lw_clnsky_flux_dn_c" , 1, 1);
1538  }
1539 
1540  // --- Chunk subviews: 2D (ncol, nswbands) ---
1541  real2d_k sfc_alb_dir_c(sfc_alb_dir.data() + col_s*nswbands, ncol_c, nswbands);
1542  real2d_k sfc_alb_dif_c(sfc_alb_dif.data() + col_s*nswbands, ncol_c, nswbands);
1543 
1544  // --- Chunk subviews: 3D (ncol, nlay+1, nbands) ---
1545  // NOTE: Allocate these once on m_ncol_chunk and use what we need in the chunk loop
1546  real3d_k sw_bnd_flux_up_c (sw_bnd_flux_up.data() , ncol_c, nlay+1, nswbands);
1547  real3d_k sw_bnd_flux_dn_c (sw_bnd_flux_dn.data() , ncol_c, nlay+1, nswbands);
1548  real3d_k sw_bnd_flux_dir_c(sw_bnd_flux_dir.data(), ncol_c, nlay+1, nswbands);
1549  real3d_k sw_bnd_flux_dif_c(sw_bnd_flux_dif.data(), ncol_c, nlay+1, nswbands);
1550  real3d_k lw_bnd_flux_up_c (lw_bnd_flux_up.data() , ncol_c, nlay+1, m_nlwbands);
1551  real3d_k lw_bnd_flux_dn_c (lw_bnd_flux_dn.data() , ncol_c, nlay+1, m_nlwbands);
1552 
1553  // --- Create chunk gas concentrations by subsetting from pre-fetched VMR ---
1554  gas_concs_t gas_concs_c;
1555  gas_concs_c.init(gas_names_offset, ncol_c, nlay);
1556  for (int igas = 0; igas < m_ngas; ++igas) {
1557  real2d_k vmr_c("vmr_c", ncol_c, nlay);
1558  auto vmr_full = vmr_full_vec[igas];
1559  auto cs = col_s;
1560  Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>>({0, 0}, {ncol_c, nlay}),
1561  KOKKOS_LAMBDA (int i, int j) {
1562  vmr_c(i, j) = vmr_full(cs + i, j);
1563  });
1564  gas_concs_c.set_vmr(m_gas_names[igas], vmr_c);
1565  }
1566 
1567  // Expand surface albedos along nswbands for this chunk
1569  sfc_alb_dir_vis_c, sfc_alb_dir_nir_c,
1570  sfc_alb_dif_vis_c, sfc_alb_dif_nir_c,
1571  sfc_alb_dir_c , sfc_alb_dif_c);
1572 
1573  // Run RRTMGP driver for this column chunk
1574  rrtmgp::rrtmgp_main(ncol_c, m_nlay,
1575  p_lay_c, t_lay_c,
1576  p_lev_c, t_lev_c,
1577  gas_concs_c,
1578  sfc_alb_dir_c, sfc_alb_dif_c, mu0_c,
1579  t_sfc_c, sfc_emis_c, lw_src_c,
1580  lwp_c, iwp_c, eff_radius_qc_c, eff_radius_qi_c, cldfrac_tot_c,
1581  sw_flux_up_c, sw_flux_dn_c, sw_flux_dn_dir_c,
1582  lw_flux_up_c, lw_flux_dn_c,
1583  sw_clnclrsky_flux_up_c, sw_clnclrsky_flux_dn_c, sw_clnclrsky_flux_dn_dir_c,
1584  sw_clrsky_flux_up_c, sw_clrsky_flux_dn_c, sw_clrsky_flux_dn_dir_c,
1585  sw_clnsky_flux_up_c, sw_clnsky_flux_dn_c, sw_clnsky_flux_dn_dir_c,
1586  lw_clnclrsky_flux_up_c, lw_clnclrsky_flux_dn_c,
1587  lw_clrsky_flux_up_c, lw_clrsky_flux_dn_c,
1588  lw_clnsky_flux_up_c, lw_clnsky_flux_dn_c,
1589  sw_bnd_flux_up_c, sw_bnd_flux_dn_c, sw_bnd_flux_dir_c,
1590  lw_bnd_flux_up_c, lw_bnd_flux_dn_c,
1591  eccf, m_do_subcol_sampling,
1593 
1594  // Compute heating rates for this chunk
1595  rrtmgp::compute_heating_rate(sw_flux_up_c, sw_flux_dn_c, r_lay_c, z_del_c, sw_heating_c);
1596  rrtmgp::compute_heating_rate(lw_flux_up_c, lw_flux_dn_c, r_lay_c, z_del_c, lw_heating_c);
1597 
1598  // Compute diffuse band fluxes and broadband surface fluxes for this chunk
1599  Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<3>>({0, 0, 0}, {ncol_c, nlay+1, nswbands}),
1600  KOKKOS_LAMBDA (int icol, int ilay, int ibnd)
1601  {
1602  sw_bnd_flux_dif_c(icol,ilay,ibnd) = sw_bnd_flux_dn_c(icol,ilay,ibnd) - sw_bnd_flux_dir_c(icol,ilay,ibnd);
1603  });
1604  rrtmgp::compute_broadband_surface_fluxes(ncol_c, kbot, nswbands,
1605  sw_bnd_flux_dir_c , sw_bnd_flux_dif_c ,
1606  sfc_flux_dir_vis_c, sfc_flux_dir_nir_c,
1607  sfc_flux_dif_vis_c, sfc_flux_dif_nir_c);
1608 
1609  gas_concs_c.reset();
1610  } // end column chunk loop
1611 }
constexpr amrex::Real mwdair
Definition: ERF_Constants.H:82
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
AMREX_GPU_HOST AMREX_FORCE_INLINE double orbital_calday(int year, int mon, int day, int sec)
Definition: ERF_OrbCosZenith.H:485
AMREX_GPU_HOST AMREX_FORCE_INLINE double orbital_cos_zenith(double &jday, double &lat, double &lon, double &declin, double dt_avg=-one, double uniform_angle=-one, double constant_zenith_angle_deg=-one)
Definition: ERF_OrbCosZenith.H:620
AMREX_GPU_HOST AMREX_FORCE_INLINE void orbital_decl(double &calday, double &eccen, double &mvelpp, double &lambm0, double &obliqr, double &delta, double &eccf)
Definition: ERF_OrbCosZenith.H:18
AMREX_GPU_HOST AMREX_FORCE_INLINE void orbital_params(int &iyear_AD, double &eccen, double &obliq, double &mvelp, double &obliqr, double &lambm0, double &mvelpp)
Definition: ERF_OrbCosZenith.H:84
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:139
double m_dt
Definition: ERF_Radiation.H:294
real(c_double), private cs
Definition: ERF_module_mp_morr_two_moment.F90:203
void rrtmgp_main(const int ncol, const int nlay, real2d_k &p_lay, real2d_k &t_lay, real2d_k &p_lev, real2d_k &t_lev, gas_concs_t &gas_concs, real2d_k &sfc_alb_dir, real2d_k &sfc_alb_dif, real1d_k &mu0, real1d_k &t_sfc, real1d_k &sfc_emis, real1d_k &lw_src, real2d_k &lwp, real2d_k &iwp, real2d_k &rel, real2d_k &rei, real2d_k &cldfrac, real2d_k &sw_flux_up, real2d_k &sw_flux_dn, real2d_k &sw_flux_dn_dir, real2d_k &lw_flux_up, real2d_k &lw_flux_dn, real2d_k &sw_clnclrsky_flux_up, real2d_k &sw_clnclrsky_flux_dn, real2d_k &sw_clnclrsky_flux_dn_dir, real2d_k &sw_clrsky_flux_up, real2d_k &sw_clrsky_flux_dn, real2d_k &sw_clrsky_flux_dn_dir, real2d_k &sw_clnsky_flux_up, real2d_k &sw_clnsky_flux_dn, real2d_k &sw_clnsky_flux_dn_dir, real2d_k &lw_clnclrsky_flux_up, real2d_k &lw_clnclrsky_flux_dn, real2d_k &lw_clrsky_flux_up, real2d_k &lw_clrsky_flux_dn, real2d_k &lw_clnsky_flux_up, real2d_k &lw_clnsky_flux_dn, real3d_k &sw_bnd_flux_up, real3d_k &sw_bnd_flux_dn, real3d_k &sw_bnd_flux_dn_dir, real3d_k &lw_bnd_flux_up, real3d_k &lw_bnd_flux_dn, const RealT tsi_scaling, const bool do_subcol_sampling, const bool extra_clnclrsky_diag, const bool extra_clnsky_diag)
Definition: ERF_RRTMGP_Interface.cpp:395
void compute_band_by_band_surface_albedos(const int ncol, const int nswbands, real1d_k &sfc_alb_dir_vis, real1d_k &sfc_alb_dir_nir, real1d_k &sfc_alb_dif_vis, real1d_k &sfc_alb_dif_nir, real2d_k &sfc_alb_dir, real2d_k &sfc_alb_dif)
Definition: ERF_RRTMGP_Interface.cpp:293
void compute_broadband_surface_fluxes(const int ncol, const int kbot, const int nswbands, real3d_k &sw_bnd_flux_dir, real3d_k &sw_bnd_flux_dif, real1d_k &sfc_flux_dir_vis, real1d_k &sfc_flux_dir_nir, real1d_k &sfc_flux_dif_vis, real1d_k &sfc_flux_dif_nir)
Definition: ERF_RRTMGP_Interface.cpp:337
void mixing_ratio_to_cloud_mass(View1 const &mixing_ratio, View2 const &cloud_fraction, View3 const &rho, View4 const &dz, View5 const &cloud_mass)
Definition: ERF_RRTMGP_Utils.H:12

Referenced by rad_run_impl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_grids()

void Radiation::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 
)
275 {
276  // Set data members that may change
277  m_lev = level;
278  m_step = step;
279  m_time = time;
280  m_dt = dt;
281  m_geom = geom;
282  m_cons_in = cons_in;
283  m_qheating_rates = qheating_rates;
284  m_rad_fluxes = rad_fluxes;
285  m_z_phys = z_phys;
286  m_z_sfc = z_sfc;
287  m_lat = lat;
288  m_lon = lon;
289 
290  // Update the day and month
291  time_t timestamp = time_t(time);
292  struct tm *timeinfo = gmtime(&timestamp);
293  if (m_fixed_orbital_year) {
294  m_orbital_mon = timeinfo->tm_mon + 1;
295  m_orbital_day = timeinfo->tm_mday;
296  m_orbital_sec = timeinfo->tm_hour*3600 + timeinfo->tm_min*60 + timeinfo->tm_sec;
297  } else {
298  m_orbital_year = timeinfo->tm_year + 1900;
299  m_orbital_mon = timeinfo->tm_mon + 1;
300  m_orbital_day = timeinfo->tm_mday;
301  m_orbital_sec = timeinfo->tm_hour*3600 + timeinfo->tm_min*60 + timeinfo->tm_sec;
302  }
303 
304  // Only allocate and proceed if we are going to update radiation
305  m_update_rad = force_update;
306  if (m_rad_freq_in_steps > 0) {
308  }
309 
310  if (m_update_rad) {
311  // Call to Init() has set the dimensions: ncol & nlay
312 
313  // Allocate the buffer arrays
314  alloc_buffers();
315 
316  // Fill the KOKKOS Views from AMReX MFs
317  mf_to_kokkos_buffers(lmask, t_surf, lsm_input_ptrs);
318 
319  // (Re)define the datalog MF whenever the grids change; this must always
320  // match the layout of cons_in since populateDatalogMF() iterates over it
321  // while indexing m_col_offsets and m_qheating_rates.
322  if (datalog_int > 0) {
323  bool needs_define = ( (datalog_mf.boxArray() != cons_in->boxArray()) ||
324  (datalog_mf.DistributionMap() != cons_in->DistributionMap()) ||
325  (datalog_mf.nComp() != nDatalogComp()) ||
326  (datalog_bdy_mf.nComp() != nDatalogBdyComp()) );
327  if (needs_define) {
328  datalog_mf.define(cons_in->boxArray(), cons_in->DistributionMap(), nDatalogComp(), 0);
329  datalog_mf.setVal(0.0);
330 
331  // Every box spans the full column (asserted in Init()), so collapsing each one to a
332  // single cell in z keeps the same box ordering and lets populateDatalogMF() share one MFIter
333  BoxList bl_bdy = cons_in->boxArray().boxList();
334  for (auto& b : bl_bdy) { b.setRange(2, 0, 1); }
335  datalog_bdy_mf.define(BoxArray(std::move(bl_bdy)), cons_in->DistributionMap(),
336  nDatalogBdyComp(), 0);
337  datalog_bdy_mf.setVal(0.0);
338  }
339  }
340  }
341 }
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
int nDatalogComp() const
Definition: ERF_Radiation.H:379
int nDatalogBdyComp() const
Definition: ERF_Radiation.H:387
int m_step
Definition: ERF_Radiation.H:288
void alloc_buffers()
Definition: ERF_Radiation.cpp:344
double m_time
Definition: ERF_Radiation.H:291

Referenced by Run().

Here is the caller graph for this function:

◆ write_rrtmgp_fluxes()

void Radiation::write_rrtmgp_fluxes ( )
938 {
939  Table2D<Real,Order::C> sw_flux_up_tab(sw_flux_up.data(), {0,0}, {static_cast<int>(sw_flux_up.extent(0)),static_cast<int>(sw_flux_up.extent(1))});
940  Table2D<Real,Order::C> sw_flux_dn_tab(sw_flux_dn.data(), {0,0}, {static_cast<int>(sw_flux_dn.extent(0)),static_cast<int>(sw_flux_dn.extent(1))});
941  Table2D<Real,Order::C> sw_flux_dn_dir_tab(sw_flux_dn_dir.data(), {0,0}, {static_cast<int>(sw_flux_dn_dir.extent(0)),static_cast<int>(sw_flux_dn_dir.extent(1))});
942  Table2D<Real,Order::C> lw_flux_up_tab(lw_flux_up.data(), {0,0}, {static_cast<int>(lw_flux_up.extent(0)),static_cast<int>(lw_flux_up.extent(1))});
943  Table2D<Real,Order::C> lw_flux_dn_tab(lw_flux_dn.data(), {0,0}, {static_cast<int>(lw_flux_dn.extent(0)),static_cast<int>(lw_flux_dn.extent(1))});
944 
945  int n_fluxes = 5;
946  MultiFab mf_flux(m_cons_in->boxArray(), m_cons_in->DistributionMap(), n_fluxes, 0);
947 
948  for (MFIter mfi(mf_flux); mfi.isValid(); ++mfi) {
949  const auto& vbx = mfi.validbox();
950  const int nx = vbx.length(0);
951  const int imin = vbx.smallEnd(0);
952  const int jmin = vbx.smallEnd(1);
953  const int offset = m_col_offsets[mfi.index()];
954  const Array4<Real>& dst_arr = mf_flux.array(mfi);
955  ParallelFor(vbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
956  {
957  // map [i,j,k] 0-based to [icol, ilay] 0-based
958  const int icol = (j-jmin)*nx + (i-imin) + offset;
959  const int ilay = k;
960 
961  // SW and LW fluxes
962  dst_arr(i,j,k,0) = sw_flux_up_tab(icol,ilay);
963  dst_arr(i,j,k,1) = sw_flux_dn_tab(icol,ilay);
964  dst_arr(i,j,k,2) = sw_flux_dn_dir_tab(icol,ilay);
965  dst_arr(i,j,k,3) = lw_flux_up_tab(icol,ilay);
966  dst_arr(i,j,k,4) = lw_flux_dn_tab(icol,ilay);
967  });
968  }
969 
970 
971  std::string plotfilename = amrex::Concatenate("plt_rad_lev" + std::to_string(m_lev) + "_", m_step, 5);
972  Vector<std::string> flux_names = {"sw_flux_up", "sw_flux_dn", "sw_flux_dir",
973  "lw_flux_up", "lw_flux_dn"};
974  WriteSingleLevelPlotfile(plotfilename, mf_flux, flux_names, m_geom, static_cast<Real>(m_time), m_step);
975 }
Here is the call graph for this function:

◆ WriteDataLog()

void Radiation::WriteDataLog ( const double &  time)
overridevirtual

Implements IRadiation.

1164 {
1165  // Columns after time, in file order. The datalog_mf components follow this order with the
1166  // disabled sets left out, and the flux columns also index the fluxes in datalog_bdy_mf.
1167  enum class Kind { Height, Heating, Mu0, Flux };
1168  struct Column { const char* name; Kind kind; bool enabled; };
1169  const bool cln = m_extra_clnsky_diag;
1170  const bool clnclr = m_extra_clnclrsky_diag;
1171  const Vector<Column> cols = {
1172  {"z_agl" , Kind::Height , true },
1173  {"sw_heating" , Kind::Heating, true },
1174  {"lw_heating" , Kind::Heating, true },
1175  {"sw_flux_up" , Kind::Flux , true },
1176  {"sw_flux_dn" , Kind::Flux , true },
1177  {"sw_flux_dn_dir" , Kind::Flux , true },
1178  {"lw_flux_up" , Kind::Flux , true },
1179  {"lw_flux_dn" , Kind::Flux , true },
1180  {"mu0" , Kind::Mu0 , true },
1181  {"sw_clrsky_heating" , Kind::Heating, true },
1182  {"lw_clrsky_heating" , Kind::Heating, true },
1183  {"sw_clrsky_flux_up" , Kind::Flux , true },
1184  {"sw_clrsky_flux_dn" , Kind::Flux , true },
1185  {"sw_clrsky_flux_dn_dir" , Kind::Flux , true },
1186  {"lw_clrsky_flux_up" , Kind::Flux , true },
1187  {"lw_clrsky_flux_dn" , Kind::Flux , true },
1188  {"sw_clnsky_flux_up" , Kind::Flux , cln },
1189  {"sw_clnsky_flux_dn" , Kind::Flux , cln },
1190  {"sw_clnsky_flux_dn_dir" , Kind::Flux , cln },
1191  {"lw_clnsky_flux_up" , Kind::Flux , cln },
1192  {"lw_clnsky_flux_dn" , Kind::Flux , cln },
1193  {"sw_clnclrsky_flux_up" , Kind::Flux , clnclr},
1194  {"sw_clnclrsky_flux_dn" , Kind::Flux , clnclr},
1195  {"sw_clnclrsky_flux_dn_dir", Kind::Flux , clnclr},
1196  {"lw_clnclrsky_flux_up" , Kind::Flux , clnclr},
1197  {"lw_clnclrsky_flux_dn" , Kind::Flux , clnclr}
1198  };
1199  const int ncols = static_cast<int>(cols.size());
1200 
1201  // Map each enabled column to its datalog_mf component and, for fluxes, its flux index
1202  Vector<int> cc_comp(ncols, -1);
1203  Vector<int> flux_comp(ncols, -1);
1204  int icc = 0;
1205  int iflux = 0;
1206  for (int c = 0; c < ncols; ++c) {
1207  if (cols[c].enabled) {
1208  cc_comp[c] = icc++;
1209  if (cols[c].kind == Kind::Flux) { flux_comp[c] = iflux++; }
1210  }
1211  }
1212  const int nflux = nDatalogFluxComp();
1213  AMREX_ALWAYS_ASSERT(icc == datalog_mf.nComp() && iflux == nflux &&
1214  datalog_bdy_mf.nComp() == nDatalogBdyComp());
1215 
1216  auto domain = m_geom.Domain();
1217  const Real area_z = static_cast<Real>(domain.length(0)*domain.length(1));
1218  const int nz = domain.length(2);
1219 
1220  // Planar averages of the cell-centered profiles
1221  Vector<Gpu::HostVector<Real>> cc_avg(icc);
1222  for (int n = 0; n < icc; ++n) {
1223  cc_avg[n] = sumToLine(datalog_mf, n, 1, domain, 2);
1224  for (auto& val : cc_avg[n]) { val /= area_z; }
1225  }
1226 
1227  // Planar averages of the surface and top-of-atmosphere values
1228  Vector<Real> bdy_avg(datalog_bdy_mf.nComp());
1229  for (int n = 0; n < datalog_bdy_mf.nComp(); ++n) { bdy_avg[n] = datalog_bdy_mf.sum(n, true); }
1230  ParallelDescriptor::ReduceRealSum(bdy_avg.data(), static_cast<int>(bdy_avg.size()));
1231  for (auto& val : bdy_avg) { val /= area_z; }
1232 
1233  if (ParallelDescriptor::IOProcessor()) {
1234  std::ostream& log = *datalog;
1235  if (log.good()) {
1236  // The log is opened in append mode, so only a new file gets the header
1237  log.seekp(0, std::ios::end);
1238  if (log.tellp() == 0) {
1239  log << "# Planar averages; each output is a block of nz+2 rows: the surface face,\n"
1240  << "# the nz cell centers, then the top-of-atmosphere face. z_agl is the height\n"
1241  << "# above ground. Heating rates exist only at cell centers and are nan on the\n"
1242  << "# face rows. Disabled clean-sky and clean-clear-sky columns are 0.\n"
1243  << "# time";
1244  for (const auto& col : cols) { log << " " << col.name; }
1245  log << std::endl;
1246  }
1247 
1248  const Real nan = std::numeric_limits<Real>::quiet_NaN();
1249 
1250  // Row -1 is the surface face, rows 0..nz-1 the cell centers, row nz the top face
1251  for (int row = -1; row <= nz; ++row)
1252  {
1253  const bool is_face = (row < 0) || (row == nz);
1254  const bool is_top = (row == nz);
1255 
1256  log << std::setw(datalog_width) << std::setprecision(datalog_time_precision) << time
1257  << std::setprecision(datalog_precision);
1258  for (int c = 0; c < ncols; ++c) {
1259  Real val = zero;
1260  if (cols[c].enabled) {
1261  if (!is_face) {
1262  val = cc_avg[cc_comp[c]][row];
1263  } else {
1264  switch (cols[c].kind) {
1265  case Kind::Height:
1266  val = (is_top) ? bdy_avg[bdyZtopComp(nflux)] : zero;
1267  break;
1268  case Kind::Heating:
1269  val = nan;
1270  break;
1271  case Kind::Mu0:
1272  val = cc_avg[cc_comp[c]][0];
1273  break;
1274  case Kind::Flux:
1275  val = bdy_avg[(is_top) ? bdyToaComp(flux_comp[c], nflux)
1276  : bdySfcComp(flux_comp[c])];
1277  break;
1278  }
1279  }
1280  }
1281  log << " ";
1282  if (c == 0) { log << std::setw(datalog_width); }
1283  log << val;
1284  }
1285  log << std::endl;
1286  } // for row
1287  } // log is good
1288  } // IOProc
1289 }
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
static constexpr int datalog_time_precision
Definition: ERF_RadiationInterface.H:119
std::unique_ptr< std::fstream > datalog
Definition: ERF_RadiationInterface.H:111
static constexpr int datalog_width
Definition: ERF_RadiationInterface.H:117
static constexpr int datalog_precision
Definition: ERF_RadiationInterface.H:118
Here is the call graph for this function:

Member Data Documentation

◆ aero_g_sw

real3d_k Radiation::aero_g_sw
private

◆ aero_ssa_sw

real3d_k Radiation::aero_ssa_sw
private

◆ aero_tau_lw

real3d_k Radiation::aero_tau_lw
private

◆ aero_tau_sw

real3d_k Radiation::aero_tau_sw
private

◆ cldfrac_tot

real2d_k Radiation::cldfrac_tot
private

◆ d_tint

real2d_k Radiation::d_tint
private

◆ datalog_bdy_mf

amrex::MultiFab Radiation::datalog_bdy_mf
private

◆ datalog_mf

amrex::MultiFab Radiation::datalog_mf
private

◆ eff_radius_qc

real2d_k Radiation::eff_radius_qc
private

◆ eff_radius_qi

real2d_k Radiation::eff_radius_qi
private

◆ gas_names_offset

std::vector<std::string> Radiation::gas_names_offset
private

◆ iwp

real2d_k Radiation::iwp
private

◆ lat

real1d_k Radiation::lat
private

◆ lon

real1d_k Radiation::lon
private

◆ lw_bnd_flux_dn

real3d_k Radiation::lw_bnd_flux_dn
private

◆ lw_bnd_flux_up

real3d_k Radiation::lw_bnd_flux_up
private

◆ lw_clnclrsky_flux_dn

real2d_k Radiation::lw_clnclrsky_flux_dn
private

◆ lw_clnclrsky_flux_up

real2d_k Radiation::lw_clnclrsky_flux_up
private

◆ lw_clnsky_flux_dn

real2d_k Radiation::lw_clnsky_flux_dn
private

◆ lw_clnsky_flux_up

real2d_k Radiation::lw_clnsky_flux_up
private

◆ lw_clrsky_flux_dn

real2d_k Radiation::lw_clrsky_flux_dn
private

◆ lw_clrsky_flux_up

real2d_k Radiation::lw_clrsky_flux_up
private

◆ lw_clrsky_heating

real2d_k Radiation::lw_clrsky_heating
private

◆ lw_flux_dn

real2d_k Radiation::lw_flux_dn
private

◆ lw_flux_up

real2d_k Radiation::lw_flux_up
private

◆ lw_heating

real2d_k Radiation::lw_heating
private

◆ lw_src

real1d_k Radiation::lw_src
private

◆ lwp

real2d_k Radiation::lwp
private

◆ m_ba

amrex::BoxArray Radiation::m_ba
private

◆ m_calday

amrex::Real Radiation::m_calday = 0.0
private

Referenced by Run().

◆ m_ch4vmr

amrex::Real Radiation::m_ch4vmr = amrex::Real(1807.851e-9)
private

◆ m_co2vmr

amrex::Real Radiation::m_co2vmr = amrex::Real(388.717e-6)
private

◆ m_col_offsets

amrex::Vector<int> Radiation::m_col_offsets
private

Referenced by Init().

◆ m_cons_in

amrex::MultiFab* Radiation::m_cons_in = nullptr
private

◆ m_covmr

amrex::Real Radiation::m_covmr = amrex::Real(1.0e-7)
private

◆ m_declin

amrex::Real Radiation::m_declin = 0.0
private

Referenced by Run().

◆ m_do_aerosol_rad

bool Radiation::m_do_aerosol_rad = false
private

◆ m_do_subcol_sampling

bool Radiation::m_do_subcol_sampling = true
private

◆ m_dt

double Radiation::m_dt
private

◆ m_extra_clnclrsky_diag

bool Radiation::m_extra_clnclrsky_diag = false
private

Referenced by nDatalogFluxComp().

◆ m_extra_clnsky_diag

bool Radiation::m_extra_clnsky_diag = false
private

Referenced by nDatalogFluxComp().

◆ m_fixed_orbital_year

bool Radiation::m_fixed_orbital_year = false
private

◆ m_fixed_solar_zenith_angle

amrex::Real Radiation::m_fixed_solar_zenith_angle
private

◆ m_fixed_total_solar_irradiance

amrex::Real Radiation::m_fixed_total_solar_irradiance = -amrex::Real(9999.)
private

◆ m_gas_concs

GasConcsK<amrex::Real, layout_t, KokkosDefaultDevice> Radiation::m_gas_concs
private

◆ m_gas_mol_weights

real1d_k Radiation::m_gas_mol_weights
private

◆ m_gas_names

const std::vector<std::string> Radiation::m_gas_names
private
Initial value:
= {"H2O", "CO2", "O3", "N2O",
"CO" , "CH4", "O2", "N2" }

◆ m_geom

amrex::Geometry Radiation::m_geom
private

◆ m_ice

bool Radiation::m_ice = false
private

◆ m_is_nested_patch

bool Radiation::m_is_nested_patch = false
private

Referenced by Init(), radiation_updated(), and Run().

◆ m_lat

amrex::MultiFab* Radiation::m_lat = nullptr
private

◆ m_lat_cons

amrex::Real Radiation::m_lat_cons
private

◆ m_lev

int Radiation::m_lev = -1
private

Referenced by Init(), and rad_run_impl().

◆ m_lon

amrex::MultiFab* Radiation::m_lon = nullptr
private

◆ m_lon_cons

amrex::Real Radiation::m_lon_cons
private

◆ m_lsm

bool Radiation::m_lsm = false
private

◆ m_lsm_input_names

amrex::Vector<std::string> Radiation::m_lsm_input_names
private
Initial value:
= {"t_sfc" , "sfc_emis" ,
"sfc_alb_dir_vis", "sfc_alb_dir_nir",
"sfc_alb_dif_vis", "sfc_alb_dif_nir"}

Referenced by get_lsm_input_varnames().

◆ m_lsm_output_names

amrex::Vector<std::string> Radiation::m_lsm_output_names
private
Initial value:
= {"cos_zenith_angle" , "sw_flux_dn" ,
"sw_flux_dn_dir_vis", "sw_flux_dn_dir_nir",
"sw_flux_dn_dif_vis", "sw_flux_dn_dif_nir",
"lw_flux_dn"}

Referenced by get_lsm_output_varnames().

◆ m_moist

bool Radiation::m_moist = false
private

◆ m_mol_weight_gas

const std::vector<amrex::Real> Radiation::m_mol_weight_gas
private
Initial value:
= {amrex::Real(18.01528), amrex::Real(44.00950), amrex::Real(47.9982), amrex::Real(44.0128),
amrex::Real(28.01010), amrex::Real(16.04246), amrex::Real(31.9980), amrex::Real(28.0134)}

◆ m_n2ovmr

amrex::Real Radiation::m_n2ovmr = amrex::Real(323.141e-9)
private

◆ m_n2vmr

amrex::Real Radiation::m_n2vmr = amrex::Real(0.7906)
private

◆ m_ncol

int Radiation::m_ncol
private

Referenced by Init().

◆ m_ncol_chunk

int Radiation::m_ncol_chunk = 1024
private

Referenced by Init().

◆ m_ncol_chunk_requested

int Radiation::m_ncol_chunk_requested = 1024
private

Referenced by Init().

◆ m_ngas

int Radiation::m_ngas = 8
private

◆ m_nlay

int Radiation::m_nlay
private

Referenced by Init(), and Run().

◆ m_nlwbands

int Radiation::m_nlwbands
private

◆ m_nlwgpts

int Radiation::m_nlwgpts
private

◆ m_nswbands

int Radiation::m_nswbands
private

◆ m_nswgpts

int Radiation::m_nswgpts
private

◆ m_o2vmr

amrex::Real Radiation::m_o2vmr = amrex::Real(0.209448)
private

◆ m_o3_size

int Radiation::m_o3_size
private

◆ m_o3vmr

amrex::Vector<amrex::Real> Radiation::m_o3vmr {amrex::Real(3.0e-8)}
private

Referenced by Init().

◆ m_orbital_day

int Radiation::m_orbital_day = -9999
private

Referenced by rad_run_impl().

◆ m_orbital_eccen

amrex::Real Radiation::m_orbital_eccen = -amrex::Real(9999.)
private

◆ m_orbital_mon

int Radiation::m_orbital_mon = -9999
private

Referenced by rad_run_impl().

◆ m_orbital_mvelp

amrex::Real Radiation::m_orbital_mvelp = -amrex::Real(9999.)
private

◆ m_orbital_obliq

amrex::Real Radiation::m_orbital_obliq = -amrex::Real(9999.)
private

◆ m_orbital_sec

int Radiation::m_orbital_sec = -9999
private

Referenced by rad_run_impl().

◆ m_orbital_year

int Radiation::m_orbital_year = -9999
private

Referenced by rad_run_impl().

◆ m_qheating_rates

amrex::MultiFab* Radiation::m_qheating_rates = nullptr
private

◆ m_qi_comp

int Radiation::m_qi_comp = -1
private

◆ m_rad_fluxes

amrex::MultiFab* Radiation::m_rad_fluxes = nullptr
private

◆ m_rad_freq_in_steps

int Radiation::m_rad_freq_in_steps
private

◆ m_rad_nvar

int Radiation::m_rad_nvar = 12
private

◆ m_rad_t_sfc

amrex::Real Radiation::m_rad_t_sfc = -1
private

◆ m_rad_write_fluxes

bool Radiation::m_rad_write_fluxes = false
private

◆ m_rdOcp

amrex::Real Radiation::m_rdOcp = RdoCp
private

◆ m_step

int Radiation::m_step
private

◆ m_time

double Radiation::m_time
private

◆ m_update_rad

bool Radiation::m_update_rad = false
private

Referenced by rad_run_impl(), and radiation_updated().

◆ m_z_phys

amrex::MultiFab* Radiation::m_z_phys = nullptr
private

◆ m_z_sfc

amrex::MultiFab* Radiation::m_z_sfc = nullptr
private

◆ max_datalog_flux

constexpr int Radiation::max_datalog_flux = n_flux_per_set * (n_flux_sets_base + n_flux_sets_optional)
staticconstexprprivate

◆ mu0

real1d_k Radiation::mu0
private

◆ n_datalog_nonflux

constexpr int Radiation::n_datalog_nonflux = 6
staticconstexprprivate

Referenced by nDatalogComp().

◆ n_flux_per_set

constexpr int Radiation::n_flux_per_set = 5
staticconstexprprivate

Referenced by nDatalogFluxComp().

◆ n_flux_sets_base

constexpr int Radiation::n_flux_sets_base = 2
staticconstexprprivate

Referenced by nDatalogFluxComp().

◆ n_flux_sets_optional

constexpr int Radiation::n_flux_sets_optional = 2
staticconstexprprivate

◆ o3_lay

real1d_k Radiation::o3_lay
private

◆ p_lay

real2d_k Radiation::p_lay
private

◆ p_lev

real2d_k Radiation::p_lev
private

◆ qc_lay

real2d_k Radiation::qc_lay
private

◆ qi_lay

real2d_k Radiation::qi_lay
private

◆ qv_lay

real2d_k Radiation::qv_lay
private

◆ r_lay

real2d_k Radiation::r_lay
private

◆ rrtmgp_cloud_optics_file_lw

std::string Radiation::rrtmgp_cloud_optics_file_lw
private

◆ rrtmgp_cloud_optics_file_sw

std::string Radiation::rrtmgp_cloud_optics_file_sw
private

◆ rrtmgp_cloud_optics_lw

std::string Radiation::rrtmgp_cloud_optics_lw = "rrtmgp-cloud-optics-coeffs-lw.nc"
private

◆ rrtmgp_cloud_optics_sw

std::string Radiation::rrtmgp_cloud_optics_sw = "rrtmgp-cloud-optics-coeffs-sw.nc"
private

◆ rrtmgp_coeffs_file_lw

std::string Radiation::rrtmgp_coeffs_file_lw
private

◆ rrtmgp_coeffs_file_sw

std::string Radiation::rrtmgp_coeffs_file_sw
private

◆ rrtmgp_coeffs_lw

std::string Radiation::rrtmgp_coeffs_lw = "rrtmgp-data-lw-g256-2018-12-04.nc"
private

◆ rrtmgp_coeffs_sw

std::string Radiation::rrtmgp_coeffs_sw = "rrtmgp-data-sw-g224-2018-12-04.nc"
private

◆ rrtmgp_file_path

std::string Radiation::rrtmgp_file_path = "."
private

◆ sfc_alb_dif

real2d_k Radiation::sfc_alb_dif
private

◆ sfc_alb_dif_nir

real1d_k Radiation::sfc_alb_dif_nir
private

◆ sfc_alb_dif_vis

real1d_k Radiation::sfc_alb_dif_vis
private

◆ sfc_alb_dir

real2d_k Radiation::sfc_alb_dir
private

◆ sfc_alb_dir_nir

real1d_k Radiation::sfc_alb_dir_nir
private

◆ sfc_alb_dir_vis

real1d_k Radiation::sfc_alb_dir_vis
private

◆ sfc_emis

real1d_k Radiation::sfc_emis
private

◆ sfc_flux_dif_nir

real1d_k Radiation::sfc_flux_dif_nir
private

◆ sfc_flux_dif_vis

real1d_k Radiation::sfc_flux_dif_vis
private

◆ sfc_flux_dir_nir

real1d_k Radiation::sfc_flux_dir_nir
private

◆ sfc_flux_dir_vis

real1d_k Radiation::sfc_flux_dir_vis
private

◆ sw_bnd_flux_dif

real3d_k Radiation::sw_bnd_flux_dif
private

◆ sw_bnd_flux_dir

real3d_k Radiation::sw_bnd_flux_dir
private

◆ sw_bnd_flux_dn

real3d_k Radiation::sw_bnd_flux_dn
private

◆ sw_bnd_flux_up

real3d_k Radiation::sw_bnd_flux_up
private

◆ sw_clnclrsky_flux_dn

real2d_k Radiation::sw_clnclrsky_flux_dn
private

◆ sw_clnclrsky_flux_dn_dir

real2d_k Radiation::sw_clnclrsky_flux_dn_dir
private

◆ sw_clnclrsky_flux_up

real2d_k Radiation::sw_clnclrsky_flux_up
private

◆ sw_clnsky_flux_dn

real2d_k Radiation::sw_clnsky_flux_dn
private

◆ sw_clnsky_flux_dn_dir

real2d_k Radiation::sw_clnsky_flux_dn_dir
private

◆ sw_clnsky_flux_up

real2d_k Radiation::sw_clnsky_flux_up
private

◆ sw_clrsky_flux_dn

real2d_k Radiation::sw_clrsky_flux_dn
private

◆ sw_clrsky_flux_dn_dir

real2d_k Radiation::sw_clrsky_flux_dn_dir
private

◆ sw_clrsky_flux_up

real2d_k Radiation::sw_clrsky_flux_up
private

◆ sw_clrsky_heating

real2d_k Radiation::sw_clrsky_heating
private

◆ sw_flux_dn

real2d_k Radiation::sw_flux_dn
private

◆ sw_flux_dn_dir

real2d_k Radiation::sw_flux_dn_dir
private

◆ sw_flux_up

real2d_k Radiation::sw_flux_up
private

◆ sw_heating

real2d_k Radiation::sw_heating
private

◆ t_lay

real2d_k Radiation::t_lay
private

◆ t_lev

real2d_k Radiation::t_lev
private

◆ t_sfc

real1d_k Radiation::t_sfc
private

◆ z_del

real2d_k Radiation::z_del
private

The documentation for this class was generated from the following files: