Skip to content

Commit

Permalink
Add plotfile for radiation model (erf-model#1790)
Browse files Browse the repository at this point in the history
* Fix loop bounds for setting zenith and pint

* Add plotfile to radiation model
  • Loading branch information
ckendrick authored Sep 6, 2024
1 parent 54226ab commit d31441e
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 58 deletions.
2 changes: 2 additions & 0 deletions Exec/Radiation/inputs_radiation
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ erf.plot_file_1 = plt # root name of plotfile
erf.plot_int_1 = 1 # number of timesteps between plotfiles
erf.plot_vars_1 = density rhotheta rhoQ1 rhoQ2 x_velocity y_velocity z_velocity pressure theta temp qt qp qv qc qi qsrc_sw qsrc_lw

erf.plot_rad = true

# SOLVER CHOICE
erf.use_gravity = true
erf.use_coriolis = false
Expand Down
2 changes: 2 additions & 0 deletions Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ private:
// Containers for additional SLM inputs
amrex::Vector<std::unique_ptr<amrex::MultiFab>> sw_lw_fluxes; // Direct SW (visible, NIR), Diffuse SW (visible, NIR), LW flux
amrex::Vector<std::unique_ptr<amrex::MultiFab>> solar_zenith; // Solar zenith angle

bool plot_rad = false;
#endif

// Fillpatcher classes for coarse-fine boundaries
Expand Down
3 changes: 3 additions & 0 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,9 @@ ERF::ReadParameters ()
pp.query("destag_profiles", destag_profiles);

pp.query("plot_lsm", plot_lsm);
#ifdef ERF_USE_RRTMGP
pp.query("plot_rad", plot_rad);
#endif

pp.query("output_1d_column", output_1d_column);
pp.query("column_per", column_per);
Expand Down
8 changes: 8 additions & 0 deletions Source/IO/Plotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,14 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
lsm.Plot_Lsm_Data(t_new[0], istep, refRatio());
}

#ifdef ERF_USE_RRTMGP
// write additional RRTMGP data
// TODO: currently single level only
if (which==1 && plot_rad) {
rad.writePlotfile(plot_file_1, t_new[0], istep[0]);
}
#endif

if (finest_level == 0)
{
if (plotfile_type == "amrex") {
Expand Down
41 changes: 36 additions & 5 deletions Source/Radiation/Radiation.H
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class Radiation {
export_surface_fluxes(FluxesByband& fluxes,
std::string band);

void yakl_to_mf(const real2d &data, amrex::MultiFab &mf);
void expand_yakl1d_to_mf(const real1d &data, amrex::MultiFab &mf);

void writePlotfile(const std::string& plot_prefix, const amrex::Real time, const int level_step);

private:
// geometry
amrex::Geometry m_geom;
Expand All @@ -103,7 +108,7 @@ class Radiation {
amrex::BoxArray m_box;

// Pointer to the radiation source terms
amrex::MultiFab* qrad_src;
amrex::MultiFab* qrad_src = nullptr;

// Pointer to latitude and longitude
amrex::MultiFab* m_lat = nullptr;
Expand Down Expand Up @@ -239,9 +244,35 @@ class Radiation {
real2d qrsc;
real2d qrlc;

real2d qt, qi, qc, qn;
real2d tmid, pmid, pdel;
real2d pint, tint;
real2d albedo_dir, albedo_dif;
// moisture inputs from ERF
real2d qt, qi, qc, qn; // [ncol, nlev]
real2d tmid, pmid, pdel; // [ncol, nlev]
real2d pint, tint; // [ncol, nlev+1]
real2d albedo_dir, albedo_dif; // [nswbands, ncol]

// timestep variables -- defined during each call to run()
real1d coszrs; // [ncol]
real2d cld, cldfsnow, iclwp, iciwp, icswp, dei, des, lambdac, mu, rei, rel; // [ncol, nlev]
// cloud, snow, and aerosol optical properties
real3d cld_tau_gpt_sw, cld_ssa_gpt_sw, cld_asm_gpt_sw; // [ncol, nlev, nswgpts]
real3d cld_tau_bnd_sw, cld_ssa_bnd_sw, cld_asm_bnd_sw; // [ncol, nlev, nswbands]
real3d aer_tau_bnd_sw, aer_ssa_bnd_sw, aer_asm_bnd_sw; // [ncol, nlev, nswbands]
real3d cld_tau_bnd_lw, aer_tau_bnd_lw; // [ncol, nlev, nlwbands]
real3d cld_tau_gpt_lw; // [ncol, nlev, nlwgpts]
// diagnostic only:
real3d liq_tau_bnd_sw, ice_tau_bnd_sw, snw_tau_bnd_sw; // [ncol, nlev, nswbands]
real3d liq_tau_bnd_lw, ice_tau_bnd_lw, snw_tau_bnd_lw; // [ncol, nlev, nlwbands]
// gas volume mixing ratios
real3d gas_vmr; // [ngas, ncol, nlev]
int1d gpoint_bands_sw, gpoint_bands_lw; // [nswgpts], [nlwgpts]
// shortwave radiation vars:
FluxesByband sw_fluxes_allsky, sw_fluxes_clrsky;
real1d cld_tau_bnd_sw_1d, cld_ssa_bnd_sw_1d, cld_asm_bnd_sw_1d; // [nswbands]
real1d cld_tau_bnd_sw_o_1d, cld_ssa_bnd_sw_o_1d, cld_asm_bnd_sw_o_1d; // [nswbands]
// aerosol optics:
real1d aer_tau_bnd_sw_1d, aer_ssa_bnd_sw_1d, aer_asm_bnd_sw_1d; // [nswbands]
real1d aer_tau_bnd_sw_o_1d, aer_ssa_bnd_sw_o_1d, aer_asm_bnd_sw_o_1d; // [nswbands]
// longwave radiation vars:
FluxesByband lw_fluxes_allsky, lw_fluxes_clrsky;
};
#endif // ERF_RADIATION_H
Loading

0 comments on commit d31441e

Please sign in to comment.