Skip to content

Commit

Permalink
More bounds fixes. (erf-model#1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi authored Apr 24, 2024
1 parent 94815bb commit aae9952
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
39 changes: 21 additions & 18 deletions Source/Radiation/Radiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,35 +263,38 @@ void Radiation::run ()
real1d coszrs("coszrs", ncol);

// Pointers to fields on the physics buffer
real2d cld("cld", ncol, nlev), cldfsnow("cldfsnow", ncol, nlev),
iclwp("iclwp", ncol, nlev), iciwp("iciwp", ncol, nlev),
icswp("icswp", ncol, nlev), dei("dei", ncol, nlev),
des("des", ncol, nlev), lambdac("lambdac", ncol, nlev),
mu("mu", ncol, nlev), rei("rei", ncol, nlev), rel("rel", ncol, nlev);
real2d cld("cld" , ncol, nlev), cldfsnow("cldfsnow", ncol, nlev),
iclwp("iclwp", ncol, nlev), iciwp("iciwp" , ncol, nlev),
icswp("icswp", ncol, nlev), dei("dei" , ncol, nlev),
des("des" , ncol, nlev), lambdac("lambdac" , ncol, nlev),
mu("mu" , ncol, nlev), rei("rei" , ncol, nlev),
rel("rel" , ncol, nlev);

// 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),
cld_asm_gpt_sw("cld_asm_gpt_sw", ncol, nlev, nswgpts);
cld_ssa_gpt_sw("cld_ssa_gpt_sw", ncol, nlev, nswgpts),
cld_asm_gpt_sw("cld_asm_gpt_sw", ncol, nlev, nswgpts);

real3d cld_tau_bnd_sw("cld_tau_bnd_sw", ncol, nlev, nswbands),
cld_ssa_bnd_sw("cld_ssa_bnd_sw", ncol, nlev, nswbands),
cld_asm_bnd_sw("cld_asm_bnd_sw", ncol, nlev, nswbands);
cld_ssa_bnd_sw("cld_ssa_bnd_sw", ncol, nlev, nswbands),
cld_asm_bnd_sw("cld_asm_bnd_sw", ncol, nlev, nswbands);

real3d aer_tau_bnd_sw("aer_tau_bnd_sw", ncol, nlev, nswbands),
aer_ssa_bnd_sw("aer_ssa_bnd_sw", ncol, nlev, nswbands),
aer_asm_bnd_sw("aer_asm_bnd_sw", ncol, nlev, nswbands);
aer_ssa_bnd_sw("aer_ssa_bnd_sw", ncol, nlev, nswbands),
aer_asm_bnd_sw("aer_asm_bnd_sw", ncol, nlev, nswbands);

real3d cld_tau_bnd_lw("cld_tau_bnd_lw", ncol, nlev, nlwbands),
aer_tau_bnd_lw("aer_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),
snw_tau_bnd_sw("snw_tau_bnd_sw", ncol, nlev, nswbands);
ice_tau_bnd_sw("ice_tau_bnd_sw", ncol, nlev, nswbands),
snw_tau_bnd_sw("snw_tau_bnd_sw", ncol, nlev, nswbands);
real3d liq_tau_bnd_lw("liq_tau_bnd_lw", ncol, nlev, nlwbands),
ice_tau_bnd_lw("ice_tau_bnd_lw", ncol, nlev, nlwbands),
snw_tau_bnd_lw("snw_tau_bnd_lw", ncol, nlev, nlwbands);
ice_tau_bnd_lw("ice_tau_bnd_lw", ncol, nlev, nlwbands),
snw_tau_bnd_lw("snw_tau_bnd_lw", ncol, nlev, nlwbands);

// Gas volume mixing ratios
real3d gas_vmr("gas_vmr", ngas, ncol, nlev);
Expand Down Expand Up @@ -706,7 +709,7 @@ void Radiation::radiation_driver_lw (int ncol, int nlev,
FluxesByband& fluxes_allsky, const real2d& qrl, const real2d& qrlc)
{
real3d cld_tau_gpt_rad("cld_tau_gpt_rad", ncol, nlev+1, nlwgpts);
real3d aer_tau_bnd_rad("aer_tau_bnd-rad", ncol, nlev+1, nlwgpts);
real3d aer_tau_bnd_rad("aer_tau_bnd_rad", ncol, nlev+1, nlwgpts);

// Surface emissivity needed for longwave
real2d surface_emissivity("surface_emissivity", nlwbands, ncol);
Expand All @@ -726,7 +729,7 @@ void Radiation::radiation_driver_lw (int ncol, int nlev,
yakl::memset(cld_tau_gpt_rad, 0.);
yakl::memset(aer_tau_bnd_rad, 0.);

parallel_for(SimpleBounds<3>(ncol, nlev, nswgpts), YAKL_LAMBDA (int icol, int ilev, int igpt)
parallel_for(SimpleBounds<3>(ncol, nlev, nlwgpts), YAKL_LAMBDA (int icol, int ilev, int igpt)
{
cld_tau_gpt_rad(icol,ilev,igpt) = cld_tau_gpt(icol,ilev,igpt);
aer_tau_bnd_rad(icol,ilev,igpt) = aer_tau_bnd(icol,ilev,igpt);
Expand Down
26 changes: 14 additions & 12 deletions Source/Radiation/Run_longwave_rrtmgp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ void Rrtmgp::run_longwave_rrtmgp (int ngas, int ncol, int nlay,

// Do the clearsky calculation before adding in clouds
FluxesByband fluxes_clrsky;
fluxes_clrsky.flux_up = real2d("clrsky_flux_up", ncol, nlay+1); // clrsky_flux_up;
fluxes_clrsky.flux_dn = real2d("clrsky_flux_up", ncol, nlay+1); //clrsky_flux_dn;
fluxes_clrsky.flux_net = real2d("clrsky_flux_up", ncol, nlay+1); //clrsky_flux_net;
fluxes_clrsky.bnd_flux_up = real3d("clrsky_flux_up", ncol, nlay+1, nlwbands); //clrsky_bnd_flux_up;
fluxes_clrsky.bnd_flux_dn = real3d("clrsky_flux_up", ncol, nlay+1, nlwbands); //clrsky_bnd_flux_dn;
fluxes_clrsky.bnd_flux_net = real3d("clrsky_flux_up", ncol, nlay+1, nlwbands); //clrsky_bnd_flux_net;
fluxes_clrsky.flux_up = real2d("clrsky_flux_up" , ncol, nlay+1); // clrsky_flux_up;
fluxes_clrsky.flux_dn = real2d("clrsky_flux_dn" , ncol, nlay+1); //clrsky_flux_dn;
fluxes_clrsky.flux_net = real2d("clrsky_flux_net", ncol, nlay+1); //clrsky_flux_net;
fluxes_clrsky.bnd_flux_up = real3d("clrsky_bnd_flux_up" , ncol, nlay+1, nlwbands); //clrsky_bnd_flux_up;
fluxes_clrsky.bnd_flux_dn = real3d("clrsky_bnd_flux_dn" , ncol, nlay+1, nlwbands); //clrsky_bnd_flux_dn;
fluxes_clrsky.bnd_flux_net = real3d("clrsky_bnd_flux_net", ncol, nlay+1, nlwbands); //clrsky_bnd_flux_net;

rte_lw(max_gauss_pts, gauss_Ds, gauss_wts, combined_optics, top_at_1, lw_sources, emis_sfc, fluxes_clrsky);

// Copy fluxes back out of FluxesByband object
Expand All @@ -125,12 +126,13 @@ void Rrtmgp::run_longwave_rrtmgp (int ngas, int ncol, int nlay,

// Call LW flux driver
FluxesByband fluxes_allsky;
fluxes_allsky.flux_up = real2d("flux_up", ncol, nlay+1); //allsky_flux_up;
fluxes_allsky.flux_dn = real2d("flux_dn", ncol, nlay+1); //allsky_flux_dn;
fluxes_allsky.flux_net = real2d("flux_net", ncol, nlay+1); //allsky_flux_net;
fluxes_allsky.bnd_flux_up = real3d("flux_up", ncol, nlay+1, nlwbands); //allsky_bnd_flux_up;
fluxes_allsky.bnd_flux_dn = real3d("flux_dn", ncol, nlay+1, nlwbands); //allsky_bnd_flux_dn;
fluxes_allsky.bnd_flux_net = real3d("flux_net", ncol, nlay+1, nlwbands); //allsky_bnd_flux_net;
fluxes_allsky.flux_up = real2d("allsky_flux_up" , ncol, nlay+1); //allsky_flux_up;
fluxes_allsky.flux_dn = real2d("allsky_flux_dn" , ncol, nlay+1); //allsky_flux_dn;
fluxes_allsky.flux_net = real2d("allsky_flux_net", ncol, nlay+1); //allsky_flux_net;
fluxes_allsky.bnd_flux_up = real3d("allsky_bnd_flux_up" , ncol, nlay+1, nlwbands); //allsky_bnd_flux_up;
fluxes_allsky.bnd_flux_dn = real3d("allsky_bnd_flux_dn" , ncol, nlay+1, nlwbands); //allsky_bnd_flux_dn;
fluxes_allsky.bnd_flux_net = real3d("allsky_bnd_flux_net", ncol, nlay+1, nlwbands); //allsky_bnd_flux_net;

rte_lw(max_gauss_pts, gauss_Ds, gauss_wts, combined_optics, top_at_1, lw_sources, emis_sfc, fluxes_allsky);

// Copy fluxes back out of FluxesByband object
Expand Down

0 comments on commit aae9952

Please sign in to comment.