diff --git a/CMake/BuildERFExe.cmake b/CMake/BuildERFExe.cmake index 215216e4c..b9219ad4b 100644 --- a/CMake/BuildERFExe.cmake +++ b/CMake/BuildERFExe.cmake @@ -78,6 +78,7 @@ function(build_erf_lib erf_lib_name) ${SRC_DIR}/Radiation/Aero_rad_props.cpp ${SRC_DIR}/Radiation/Optics.cpp ${SRC_DIR}/Radiation/Radiation.cpp + ${SRC_DIR}/Radiation/Albedo.cpp ${CMAKE_SOURCE_DIR}/Submodules/RRTMGP/cpp/examples/mo_load_coefficients.cpp ${CMAKE_SOURCE_DIR}/Submodules/RRTMGP/cpp/extensions/fluxes_byband/mo_fluxes_byband_kernels.cpp ) @@ -146,6 +147,7 @@ function(build_erf_lib erf_lib_name) ${SRC_DIR}/TimeIntegration/ERF_TimeStep.cpp ${SRC_DIR}/TimeIntegration/ERF_advance_dycore.cpp ${SRC_DIR}/TimeIntegration/ERF_advance_microphysics.cpp + ${SRC_DIR}/TimeIntegration/ERF_advance_radiation.cpp ${SRC_DIR}/TimeIntegration/ERF_make_buoyancy.cpp ${SRC_DIR}/TimeIntegration/ERF_make_condensation_source.cpp ${SRC_DIR}/TimeIntegration/ERF_make_fast_coeffs.cpp diff --git a/Source/ERF.H b/Source/ERF.H index 60d649eab..0f8adfc1f 100644 --- a/Source/ERF.H +++ b/Source/ERF.H @@ -48,6 +48,10 @@ #include "Microphysics.H" #endif +#ifdef ERF_USE_RRTMGP +#include "Radiation.H" +#endif + #ifdef ERF_USE_NETCDF #include "NCWpsFile.H" #endif @@ -218,6 +222,12 @@ public: const amrex::Real& dt_advance); #endif +#if defined(ERF_USE_RRTMGP) + void advance_radiation (int lev, + amrex::MultiFab& cons_in, + const amrex::Real& dt_advance); +#endif + amrex::MultiFab& build_fine_mask (int lev); void MakeHorizontalAverages (); @@ -535,6 +545,10 @@ private: amrex::Vector qmoist; // This has 6 components: qv, qc, qi, qr, qs, qg #endif +#if defined(ERF_USE_RRTMGP) + Radiation rad; +#endif + // Fillpatcher classes for coarse-fine boundaries int cf_width{0}; int cf_set_width{0}; diff --git a/Source/Radiation/Aero_rad_props.H b/Source/Radiation/Aero_rad_props.H index b92df6049..de440576c 100644 --- a/Source/Radiation/Aero_rad_props.H +++ b/Source/Radiation/Aero_rad_props.H @@ -4,7 +4,7 @@ #ifndef ERF_AER_RAD_PROPS_H_ #define ERF_AER_RAD_PROPS_H_ -#include "ERF.H" +#include #include "Mam4_aero.H" #include "YAKL_netcdf.h" #include "rrtmgp_const.h" diff --git a/Source/Radiation/Aero_rad_props.cpp b/Source/Radiation/Aero_rad_props.cpp index 02381dd7b..b01c94b9c 100644 --- a/Source/Radiation/Aero_rad_props.cpp +++ b/Source/Radiation/Aero_rad_props.cpp @@ -3,8 +3,8 @@ // #include -#include "Aero_rad_props.H" #include "ERF_Constants.H" +#include "Aero_rad_props.H" #include "Water_vapor_saturation.H" void AerRadProps::initialize() { diff --git a/Source/Radiation/Albedo.H b/Source/Radiation/Albedo.H index bbb971fc8..7fc8cc150 100644 --- a/Source/Radiation/Albedo.H +++ b/Source/Radiation/Albedo.H @@ -9,14 +9,5 @@ */ #ifndef ERF_ALBEDO_H_ #define ERF_ALBEDO_H_ -void set_albedo(const real1d& coszrs, real2d& albedo_dir, real2d& albedo_dif) -{ - // Albedos for land type I (Briegleb) - auto nswbands = albedo_dir.extent(0); - auto ncol = albedo_dif.extent(1); - yakl::c::parallel_for(yakl::c::Bounds<2>(nswbands,ncol), YAKL_LAMBDA (int ibnd, int icol) { - albedo_dir(ibnd, icol) = 1.4 * 0.24 / ( 1. + 0.8 * coszrs(icol)); - albedo_dif(ibnd, icol) = 1.2 * 0.24; - }); -} +void set_albedo(const real1d& coszrs, real2d& albedo_dir, real2d& albedo_dif); #endif diff --git a/Source/Radiation/Albedo.cpp b/Source/Radiation/Albedo.cpp new file mode 100644 index 000000000..d4414d4e9 --- /dev/null +++ b/Source/Radiation/Albedo.cpp @@ -0,0 +1,15 @@ + +#include +#include "Albedo.H" + +void set_albedo(const real1d& coszrs, real2d& albedo_dir, real2d& albedo_dif) +{ + // Albedos for land type I (Briegleb) + auto nswbands = albedo_dir.extent(0); + auto ncol = albedo_dif.extent(1); + yakl::c::parallel_for(yakl::c::Bounds<2>(nswbands,ncol), YAKL_LAMBDA (int ibnd, int icol) { + albedo_dir(ibnd, icol) = 1.4 * 0.24 / ( 1. + 0.8 * coszrs(icol)); + albedo_dif(ibnd, icol) = 1.2 * 0.24; + }); +} + diff --git a/Source/Radiation/Cloud_rad_props.H b/Source/Radiation/Cloud_rad_props.H index 748812bcf..dbcd80606 100644 --- a/Source/Radiation/Cloud_rad_props.H +++ b/Source/Radiation/Cloud_rad_props.H @@ -4,9 +4,11 @@ #ifndef ERF_CLOUD_RAD_PROPS_H_ #define ERF_CLOUD_RAD_PROPS_H_ -#include "ERF.H" -#include "Linear_interpolate.H" +#include +#include "ERF_Constants.H" #include "rrtmgp_const.h" +#include "Water_vapor_saturation.H" +#include "Linear_interpolate.H" class CloudRadProps { public: diff --git a/Source/Radiation/Cloud_rad_props.cpp b/Source/Radiation/Cloud_rad_props.cpp index 3c23fac83..c865d4702 100644 --- a/Source/Radiation/Cloud_rad_props.cpp +++ b/Source/Radiation/Cloud_rad_props.cpp @@ -3,8 +3,6 @@ // #include "YAKL_netcdf.h" #include "Cloud_rad_props.H" -#include "Water_vapor_saturation.H" -#include "Linear_interpolate.H" void CloudRadProps::initialize() { realHost1d g_mu_h; // mu samples on grid diff --git a/Source/Radiation/Radiation.H b/Source/Radiation/Radiation.H index cfa7a7f6c..8284a97fa 100644 --- a/Source/Radiation/Radiation.H +++ b/Source/Radiation/Radiation.H @@ -4,7 +4,7 @@ * https://github.com/earth-system-radiation/rte-rrtmgp * Please reference to the following paper, * https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2019MS001621 - * NOTE: we use the C++ version of RTE-RRTMGP, which is reimplemented the original Fortran + * NOTE: we use the C++ version of RTE-RRTMGP, which is the implemention of the original Fortran * code using C++ YAKL for CUDA, HiP and SYCL application by E3SM ECP team, the C++ version * of the rte-rrtmgp code is located at: * https://github.com/E3SM-Project/rte-rrtmgp @@ -28,6 +28,8 @@ #include "Rrtmgp.H" #include "Optics.H" #include "Aero_rad_props.H" +#include "Parameterizations.H" +#include "Albedo.H" // Radiation code interface class class Radiation { @@ -36,57 +38,54 @@ class Radiation { ~Radiation() = default; // init - void initialize (const amrex::MultiFab& cons_in, - const amrex::MultiFab& qc_in, - const amrex::MultiFab& qv_in, - const amrex::MultiFab& qi_in, - const amrex::BoxArray& grids, - const amrex::Geometry& geom, - const amrex::Real& dt_advance, - const bool& do_sw_rad, - const bool& do_lw_rad, - const bool& do_aero_rad, - const bool& do_snow_opt, - const bool& is_cmip6_volcano); + void initialize(const amrex::MultiFab& cons_in, amrex::MultiFab& qmoist, + const amrex::BoxArray& grids, + const amrex::Geometry& geom, + const amrex::Real& dt_advance, + const bool& do_sw_rad, + const bool& do_lw_rad, + const bool& do_aero_rad, + const bool& do_snow_opt, + const bool& is_cmip6_volcano); // run radiation model - void run (); + void run(); // call back - void on_complete (); - - void radiation_driver_lw (int ncol, int nlev, - real3d& gas_vmr, - real2d& pmid, real2d& pint, real2d& tmid, real2d& tint, - real3d& cld_tau_gpt, real3d& aer_tau_bnd, - FluxesByband& fluxes_clrsky, FluxesByband& fluxes_allsky, - real2d& qrl, real2d& qrlc); - - void radiation_driver_sw (int ncol, - real3d& gas_vmr, real2d& pmid, real2d& pint, real2d& tmid, - real2d& albedo_dir, real2d& albedo_dif, real1d& coszrs, - real3d& cld_tau_gpt, real3d& cld_ssa_gpt, real3d& cld_asm_gpt, - real3d& aer_tau_bnd, real3d& aer_ssa_bnd, real3d& aer_asm_bnd, - FluxesByband& fluxes_clrsky, FluxesByband& fluxes_allsky, - real2d& qrs, real2d& qrsc); - - void set_daynight_indices (real1d& coszrs, - int1d& day_indices, - int1d& night_indices); - - void get_gas_vmr (std::vector& gas_names, - real3d& gas_vmr); - - void calculate_heating_rate (real2d& flux_up, - real2d& flux_dn, - real2d& pint, - real2d& heating_rate); -private: + void on_complete(); + + void radiation_driver_lw(int ncol, int nlev, + real3d& gas_vmr, + real2d& pmid, real2d& pint, real2d& tmid, real2d& tint, + real3d& cld_tau_gpt, real3d& aer_tau_bnd, + FluxesByband& fluxes_clrsky, FluxesByband& fluxes_allsky, + real2d& qrl, real2d& qrlc); + + void radiation_driver_sw(int ncol, + real3d& gas_vmr, real2d& pmid, real2d& pint, real2d& tmid, + real2d& albedo_dir, real2d& albedo_dif, real1d& coszrs, + real3d& cld_tau_gpt, real3d& cld_ssa_gpt, real3d& cld_asm_gpt, + real3d& aer_tau_bnd, real3d& aer_ssa_bnd, real3d& aer_asm_bnd, + FluxesByband& fluxes_clrsky, FluxesByband& fluxes_allsky, + real2d& qrs, real2d& qrsc); + + void set_daynight_indices(real1d& coszrs, + int1d& day_indices, + int1d& night_indices); + + void get_gas_vmr(const std::vector& gas_names, + real3d& gas_vmr); + + void calculate_heating_rate(real2d& flux_up, + real2d& flux_dn, + real2d& pint, + real2d& heating_rate); + private: // geometry amrex::Geometry m_geom; // valid boxes on which to evolve the solution - amrex::BoxArray m_gtoe; + amrex::BoxArray m_box; // number of vertical levels int nlev, zlo, zhi; @@ -119,7 +118,7 @@ private: // // Net flux calculated in this routine; used to check energy conservation in // the physics package driver? - real1d net_flux; //("net_flux",ncol); + real1d net_flux; // This should be module data or something specific to aerosol where it is used? bool is_cmip6_volc; // true if cmip6 style volcanic file is read otherwise false @@ -127,11 +126,11 @@ private: real dt; // time step(s) - needed for aerosol optics call // Surface and top fluxes - real1d fsns; //(pcols) ! Surface solar absorbed flux - real1d fsnt; //(pcols) ! Net column abs solar flux at model top - real1d flns; //(pcols) ! Srf longwave cooling (up-down) flux - real1d flnt; //(pcols) ! Net outgoing lw flux at model top - real1d fsds; //(pcols) ! Surface solar down flux + real1d fsns; //(ncols) ! Surface solar absorbed flux + real1d fsnt; //(ncols) ! Net column abs solar flux at model top + real1d flns; //(ncols) ! Srf longwave cooling (up-down) flux + real1d flnt; //(ncols) ! Net outgoing lw flux at model top + real1d fsds; //(ncols) ! Surface solar down flux // radiation data const std::vector active_gases = { @@ -186,8 +185,8 @@ private: int1d rrtmg_to_rrtmgp; // Pointers to heating rates on physics buffer - real2d qrs; //(:,:) ! shortwave radiative heating rate - real2d qrl; //(:,:) ! longwave radiative heating rate + real2d qrs; // shortwave radiative heating rate + real2d qrl; // longwave radiative heating rate // Pointers to fields on the physics buffer real2d zi; @@ -195,11 +194,8 @@ private: // Clear-sky heating rates are not on the physics buffer, and we have no // reason to put them there, so declare these are regular arrays here - real2d qrsc; //(pcols,pver) - real2d qrlc; //(pcols,pver) - - // Temporary variable for heating rate output - real2d hr; + real2d qrsc; + real2d qrlc; real2d tmid, pmid, pdel; real2d pint, tint; diff --git a/Source/Radiation/Radiation.cpp b/Source/Radiation/Radiation.cpp index d60bdad54..f7170f8d1 100644 --- a/Source/Radiation/Radiation.cpp +++ b/Source/Radiation/Radiation.cpp @@ -72,20 +72,18 @@ namespace internal { } // init -void Radiation::initialize(const amrex::MultiFab& cons_in, - const amrex::MultiFab& qc_in, - const amrex::MultiFab& qv_in, - const amrex::MultiFab& qi_in, - const amrex::BoxArray& grids, - const amrex::Geometry& geom, - const amrex::Real& dt_advance, +void Radiation::initialize(const MultiFab& cons_in, MultiFab& qmoist, + const BoxArray& grids, + const Geometry& geom, + const Real& dt_advance, const bool& do_sw_rad, const bool& do_lw_rad, const bool& do_aero_rad, const bool& do_snow_opt, const bool& is_cmip6_volcano) { + m_geom = geom; - m_gtoe = grids; + m_box = grids; auto dz = m_geom.CellSize(2); auto lowz = m_geom.ProbLo(2); @@ -108,14 +106,11 @@ void Radiation::initialize(const amrex::MultiFab& cons_in, // initialize cloud, aerosol, and radiation optics.initialize(); - radiation.initialize(); - - // Setup the RRTMGP interface - //rrtmgp_initialize(ngas, active_gases, rrtmgp_coefficients_file_sw, rrtmgp_coefficients_file_lw); - radiation.initialize(); + radiation.initialize(ngas, active_gases, + rrtmgp_coefficients_file_sw.c_str(), + rrtmgp_coefficients_file_lw.c_str()); // initialize the radiation data - auto nswbands = radiation.get_nband_sw(); auto nswgpts = radiation.get_ngpt_sw(); auto nlwbands = radiation.get_nband_lw(); @@ -130,9 +125,6 @@ void Radiation::initialize(const amrex::MultiFab& cons_in, } }); - // Temporary variable for heating rate output - hr = real2d("hr", ncol, nlev); - tmid = real2d("tmid", ncol, nlev); pmid = real2d("pmid", ncol, nlev); @@ -142,6 +134,14 @@ void Radiation::initialize(const amrex::MultiFab& cons_in, albedo_dir = real2d("albedo_dir", nswbands, ncol); albedo_dif = real2d("albedo_dif", nswbands, ncol); + qrs = real2d("qrs", ncol, nlev); // shortwave radiative heating rate + qrl = real2d("qrl", ncol, nlev); // longwave radiative heating rate + + // Clear-sky heating rates are not on the physics buffer, and we have no + // reason to put them there, so declare these are regular arrays here + qrsc = real2d("qrsc", ncol, nlev); + qrlc = real2d("qrlc", ncol, nlev); + amrex::Print() << " LW coefficents file: " // a/, & << " SW coefficents file: " // a/, & << " Frequency (timesteps) of Shortwave Radiation calc: " //,i5/, & @@ -158,8 +158,12 @@ void Radiation::initialize(const amrex::MultiFab& cons_in, // run radiation model void Radiation::run() { - real2d qrs("qrs", ncol, nlev); // shortwave radiative heating rate - real2d qrl("qrl", ncol, nlev); // longwave radiative heating rate + // local variables + // Temporary variable for heating rate output + real2d hr("hr", ncol, nlev); + + // Cosine solar zenith angle for all columns in chunk + real1d coszrs("coszrs", ncol); // Pointers to fields on the physics buffer real2d cld("cld", ncol, nlev), cldfsnow("cldfsnow", ncol, nlev), @@ -168,24 +172,6 @@ void Radiation::run() { des("des", ncol, nlev), lambdac("lambdac", ncol, nlev), mu("mu", ncol, nlev), rei("rei", ncol, nlev), rel("rel", ncol, nlev); - // Clear-sky heating rates are not on the physics buffer, and we have no - // reason to put them there, so declare these are regular arrays here - real2d qrsc("qrsc", ncol, nlev); - real2d qrlc("qrlc", ncol, nlev); - - // Temporary variable for heating rate output - real2d hr("hr", ncol, nlev); - - real2d tmid("tmid", ncol, nlev), - pmid("pmid", ncol, nlev); - real2d pint("pint", ncol, nlev+1 ), - tint("tint", ncol, nlev+1); - real2d albedo_dir("albedo_dir", nswbands, ncol), - albedo_dif("albedo_dif", nswbands, ncol); - - // Cosine solar zenith angle for all columns in chunk - real1d coszrs("coszrs", ncol); - // Cloud, snow, and aerosol optical properties real3d cld_tau_gpt_sw("cld_tau_gpt_sw", ncol, nlev, nswgpts), cld_ssa_gpt_sw("cld_ssa_gpt_sw", ncol, nlev, nswgpts), @@ -199,6 +185,7 @@ void Radiation::run() { real3d cld_tau_bnd_lw("cld_tau_bnd_lw", ncol, nlev, nlwbands), aer_tau_bnd_lw("aer_tau_bnd_lw", ncol, nlev, nlwbands); real3d cld_tau_gpt_lw("cld_tau_gpt_lw", ncol, nlev, nlwgpts); + // NOTE: these are diagnostic only real3d liq_tau_bnd_sw("liq_tau_bnd_sw", ncol, nlev, nswbands), ice_tau_bnd_sw("ice_tau_bnd_sw", ncol, nlev, nswbands), @@ -234,12 +221,13 @@ void Radiation::run() { internal::initial_fluxes(ncol, nlev, nlwbands, fluxes_allsky); internal::initial_fluxes(ncol, nlev, nlwbands, fluxes_clrsky); + // Get cosine solar zenith angle for current time step. ( still NOT YET implemented here) +// set_cosine_solar_zenith_angle(state, dt_avg, coszrs(1:ncol)) + yakl::memset(coszrs, 0.2); // we set constant value here to avoid numerical overflow. + // Get albedo. This uses CAM routines internally and just provides a // wrapper to improve readability of the code here. -// set_albedo(cam_in, albedo_dir(1:nswbands,1:ncol), albedo_dif(1:nswbands,1:ncol)) - - // Get cosine solar zenith angle for current time step. -// set_cosine_solar_zenith_angle(state, dt_avg, coszrs(1:ncol)) + set_albedo(coszrs, albedo_dir, albedo_dif); // Do shortwave cloud optics calculations yakl::memset(cld_tau_gpt_sw, 0.); @@ -252,11 +240,6 @@ void Radiation::run() { cld_tau_bnd_sw, cld_ssa_bnd_sw, cld_asm_bnd_sw, liq_tau_bnd_sw, ice_tau_bnd_sw, snw_tau_bnd_sw); - // Output the band-by-band cloud optics BEFORE we reorder bands, because - // we hard-coded the indices for diagnostic bands in radconstants.F90 to - // correspond to the optical property look-up tables. -// output_cloud_optics_sw(state, cld_tau_bnd_sw, cld_ssa_bnd_sw, cld_asm_bnd_sw); - // Now reorder bands to be consistent with RRTMGP // We need to fix band ordering because the old input files assume RRTMG // band ordering, but this has changed in RRTMGP. @@ -305,13 +288,10 @@ void Radiation::run() { if (night_indices(icol) > 0) nnight++; } - // Loop over diagnostic calls -// rad_cnst_get_call_list(active_calls); - - for (auto icall = 1 /*N_DIAG*/; icall > 0; --icall) { + for (auto icall = ngas /*N_DIAG*/; icall > 0; --icall) { // if (active_calls(icall)) { // Get gas concentrations -// get_gas_vmr(icall, active_gases, gas_vmr); + get_gas_vmr(active_gases, gas_vmr); // Get aerosol optics if (do_aerosol_rad) { @@ -354,14 +334,6 @@ void Radiation::run() { yakl::memset(aer_asm_bnd_sw, 0.); } - // Check (and possibly clip) values before passing to RRTMGP driver - // handle_error(clip_values(cld_tau_gpt_sw, 0._r8, huge(cld_tau_gpt_sw), trim(subname) // ' cld_tau_gpt_sw', tolerance=1e-10_r8)) - // handle_error(clip_values(cld_ssa_gpt_sw, 0._r8, 1._r8, trim(subname) // ' cld_ssa_gpt_sw', tolerance=1e-10_r8)) - // handle_error(clip_values(cld_asm_gpt_sw, -1._r8, 1._r8, trim(subname) // ' cld_asm_gpt_sw', tolerance=1e-10_r8)) - // handle_error(clip_values(aer_tau_bnd_sw, 0._r8, huge(aer_tau_bnd_sw), trim(subname) // ' aer_tau_bnd_sw', tolerance=1e-10_r8)) - // handle_error(clip_values(aer_ssa_bnd_sw, 0._r8, 1._r8, trim(subname) // ' aer_ssa_bnd_sw', tolerance=1e-10_r8)) - // handle_error(clip_values(aer_asm_bnd_sw, -1._r8, 1._r8, trim(subname) // ' aer_asm_bnd_sw', tolerance=1e-10_r8)) - // Call the shortwave radiation driver radiation_driver_sw( ncol, gas_vmr, @@ -372,8 +344,6 @@ void Radiation::run() { ); } - // Set net fluxes used by other components (land?) -// set_net_fluxes_sw(fluxes_allsky, fsds, fsns, fsnt); } else { // Conserve energy @@ -413,10 +383,10 @@ void Radiation::run() { // Loop over diagnostic calls //rad_cnst_get_call_list(active_calls); - for (auto icall = 1; /*N_DIAG;*/ icall > 0; --icall) { + for (auto icall = ngas; /*N_DIAG;*/ icall > 0; --icall) { // if (active_calls(icall)) { // Get gas concentrations - //get_gas_vmr(icall, active_gases, gas_vmr); + get_gas_vmr(active_gases, gas_vmr); // Get aerosol optics yakl::memset(aer_tau_bnd_lw, 0.); @@ -425,22 +395,10 @@ void Radiation::run() { aer_rad.aer_rad_props_lw(is_cmip6_volc, icall, dt, zi, aer_tau_bnd_lw, clear_rh); } - // Check (and possibly clip) values before passing to RRTMGP driver - //handle_error(clip_values(cld_tau_gpt_lw, 0._r8, huge(cld_tau_gpt_lw), trim(subname) // ': cld_tau_gpt_lw', tolerance=1e-10_r8)) - //handle_error(clip_values(aer_tau_bnd_lw, 0._r8, huge(aer_tau_bnd_lw), trim(subname) // ': aer_tau_bnd_lw', tolerance=1e-10_r8)) - // Call the longwave radiation driver to calculate fluxes and heating rates radiation_driver_lw(ncol, nlev, gas_vmr, pmid, pint, tmid, tint, cld_tau_gpt_lw, aer_tau_bnd_lw, fluxes_allsky, fluxes_clrsky, qrl, qrlc); - // Send fluxes to history buffer - // call output_fluxes_lw(icall, state, fluxes_allsky, fluxes_clrsky, qrl, qrlc) } - - // Set net fluxes used in other components - //set_net_fluxes_lw(fluxes_allsky, flns, flnt); - - // Export surface fluxes that are used by the land model - //call export_surface_fluxes(fluxes_allsky, cam_out, 'longwave') } else { // Conserve energy (what does this mean exactly?) @@ -454,11 +412,6 @@ void Radiation::run() { } // dolw - // Compute net radiative heating tendency -// radheat_tend(ptend, qrl, qrs, -// fsns, fsnt, flns, flnt, -// cam_in%asdir, net_flux); - // Compute heating rate for dtheta/dt for (auto ilay = 1; ilay < nlev; ++nlev) { for (auto icol = 1; icol < ncol; ++icol) { @@ -691,8 +644,7 @@ void Radiation::set_daynight_indices(real1d& coszrs, int1d& day_indices, int1d& // Loop over columns and identify daytime columns as those where the cosine // solar zenith angle exceeds zero. Note that we wrap the setting of // day_indices in an if-then to make sure we are not accesing day_indices out - // of bounds, and stopping with an informative error message if we do for some - // reason. + // of bounds, and stopping with an informative error message if we do for some reason. int iday = 0; int inight = 0; for (auto icol = 0; icol < ncol; ++icol) { @@ -706,7 +658,7 @@ void Radiation::set_daynight_indices(real1d& coszrs, int1d& day_indices, int1d& } } -void Radiation::get_gas_vmr(std::vector& gas_names, real3d& gas_vmr) { +void Radiation::get_gas_vmr(const std::vector& gas_names, real3d& gas_vmr) { // Mass mixing ratio real2d mmr("mmr", ncol, nlev); // Gases and molecular weights. Note that we do NOT have CFCs yet (I think diff --git a/Source/Radiation/Rrtmgp.H b/Source/Radiation/Rrtmgp.H index 9cca6a6f4..54b9412c3 100644 --- a/Source/Radiation/Rrtmgp.H +++ b/Source/Radiation/Rrtmgp.H @@ -20,7 +20,6 @@ #include #include -#include #include // rrtmgp includes diff --git a/Source/TimeIntegration/ERF_advance_radiation.cpp b/Source/TimeIntegration/ERF_advance_radiation.cpp new file mode 100644 index 000000000..c04904c0f --- /dev/null +++ b/Source/TimeIntegration/ERF_advance_radiation.cpp @@ -0,0 +1,29 @@ + +#include + +using namespace amrex; + +#if defined(ERF_USE_RRTMGP) +void ERF::advance_radiation (int lev, + MultiFab& cons, + const Real& dt_advance) +{ + bool do_sw_rad {true}; + bool do_lw_rad {true}; + bool do_aero_rad {true}; + bool do_snow_opt {true}; + bool is_cmip6_volcano {true}; + + rad.initialize(cons, qmoist[lev], + grids[lev], + Geom(lev), + dt_advance, + do_sw_rad, + do_lw_rad, + do_aero_rad, + do_snow_opt, + is_cmip6_volcano); +// rad.run(); + rad.on_complete(); +} +#endif