|
ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
|
CSV logger and debug-print manager for radiation module. More...
#include <ERF_RadiationDiagnostics.H>

Public Member Functions | |
| RadiationDiagnostics (int verbosity, const std::string &diag_file, int amr_level, bool diag_enable=true, bool diag_stdout_enable=true, bool diag_tagged_enable=true, bool diag_regtest_line_enable=true, bool diag_csv_enable=true, const std::string &diag_callsite_mode="both", amrex::Real diag_dedup_tol=1.0e-12) | |
| Constructor. More... | |
| ~RadiationDiagnostics () | |
| Destructor. More... | |
| void | append (int step, amrex::Real time, std::string const &call_site, amrex::Real sw_surface, amrex::Real sw_toa, amrex::Real sw_up_toa, amrex::Real lw_net_surface, amrex::Real lw_up_toa, amrex::Real heating_rate_max, amrex::Real seb_residual_mean=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real seb_residual_max=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real t_s_mean=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real t_s_max=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real q_s_mean=std::numeric_limits< amrex::Real >::quiet_NaN(), amrex::Real q_s_max=std::numeric_limits< amrex::Real >::quiet_NaN()) |
| Append a diagnostic row to the CSV file. More... | |
Private Member Functions | |
| void | write_header_if_needed () |
| Write CSV header if file is new or doesn't exist. More... | |
Private Attributes | |
| int | m_verbosity |
| Debug verbosity level. More... | |
| std::string | m_diag_file |
| Output CSV file path. More... | |
| int | m_amr_level = 0 |
| AMR level this instance reports for. More... | |
| int | m_last_write_step = -1 |
| Guard against duplicate writes. More... | |
| bool | m_header_written = false |
| Track whether CSV header was written. More... | |
| std::string | m_last_write_call_site = "" |
| amrex::Real | m_last_write_time = -1.0 |
| bool | m_diag_enable = true |
| bool | m_diag_stdout_enable = true |
| bool | m_diag_tagged_enable = true |
| bool | m_diag_regtest_line_enable = true |
| bool | m_diag_csv_enable = true |
| std::string | m_diag_callsite_mode = "both" |
| amrex::Real | m_diag_dedup_tol = 1.0e-12 |
CSV logger and debug-print manager for radiation module.
Manages output of radiation diagnostics including:
Dedup Contract:
Each AMR level owns its own RadiationDiagnostics, so the identity below is implicitly per level: two levels reporting the same step, call_site and time are distinct instances and neither suppresses the other. All instances append to the same CSV, which carries a level column to tell the rows apart.
Duplicate detection uses a 3-tuple identity (step, call_site, time):
This ensures:
Follows the duplicate-write-guard pattern from UCMDiagnostics.
| RadiationDiagnostics::RadiationDiagnostics | ( | int | verbosity, |
| const std::string & | diag_file, | ||
| int | amr_level, | ||
| bool | diag_enable = true, |
||
| bool | diag_stdout_enable = true, |
||
| bool | diag_tagged_enable = true, |
||
| bool | diag_regtest_line_enable = true, |
||
| bool | diag_csv_enable = true, |
||
| const std::string & | diag_callsite_mode = "both", |
||
| amrex::Real | diag_dedup_tol = 1.0e-12 |
||
| ) |
Constructor.
| [in] | verbosity | Debug verbosity level (0=off, 1+=print). |
| [in] | diag_file | Output CSV file path (relative to working directory). |
| [in] | amr_level | AMR level this instance reports for. Written as the level CSV column and tagged onto the stdout lines. One instance per level, so the duplicate guard below is per level and a fine level's row is never mistaken for a coarse one. |
| [in] | diag_enable | Master switch for all diagnostics. |
| [in] | diag_stdout_enable | Enable human-readable stdout block. |
| [in] | diag_tagged_enable | Enable tagged debug lines. |
| [in] | diag_regtest_line_enable | Enable RADIATION_DIAG: lines. |
| [in] | diag_csv_enable | Enable CSV file writes. |
| [in] | diag_callsite_mode | Call-site filter: "both", "pre_only", "post_only". |
| [in] | diag_dedup_tol | Tolerance for time equality in duplicate guard. |
| RadiationDiagnostics::~RadiationDiagnostics | ( | ) |
| void RadiationDiagnostics::append | ( | int | step, |
| amrex::Real | time, | ||
| std::string const & | call_site, | ||
| amrex::Real | sw_surface, | ||
| amrex::Real | sw_toa, | ||
| amrex::Real | sw_up_toa, | ||
| amrex::Real | lw_net_surface, | ||
| amrex::Real | lw_up_toa, | ||
| amrex::Real | heating_rate_max, | ||
| amrex::Real | seb_residual_mean = std::numeric_limits<amrex::Real>::quiet_NaN(), |
||
| amrex::Real | seb_residual_max = std::numeric_limits<amrex::Real>::quiet_NaN(), |
||
| amrex::Real | t_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN(), |
||
| amrex::Real | t_s_max = std::numeric_limits<amrex::Real>::quiet_NaN(), |
||
| amrex::Real | q_s_mean = std::numeric_limits<amrex::Real>::quiet_NaN(), |
||
| amrex::Real | q_s_max = std::numeric_limits<amrex::Real>::quiet_NaN() |
||
| ) |
Append a diagnostic row to the CSV file.
Records a row of radiation diagnostics for the current timestep:
CSV columns (order): step, time, call_site, SW_surface, SW_TOA, SW_up_TOA, LW_net_surface, LW_up_TOA, heating_rate_max [optional]: SEB_residual_mean, SEB_residual_max (only if seb_diagnostic_enable=true) [optional]: T_s_mean, T_s_max, q_s_mean, q_s_max level – appended last, following this file's rule that new columns go at the end so existing header-name parsers keep working.
Also prints tagged debug output and RADIATION_DIAG: line for RegTest parsing.
Guards against duplicate writes (uses m_last_write_step).
| [in] | step | Current timestep number. |
| [in] | time | Current simulation time [s]. |
| [in] | call_site | Diagnostic call-site label (e.g., "pre_dycore", "post_dycore"). |
| [in] | SW_surface | SW absorbed by the surface, (1 - albedo) * incident [W/m^2]. |
| [in] | SW_TOA | Incident SW at the top of the atmosphere [W/m^2]. |
| [in] | SW_up_TOA | Reflected SW leaving the top of the atmosphere [W/m^2]. |
| [in] | LW_net_surface | Net LW (up - down) at the surface [W/m^2]. |
| [in] | LW_up_TOA | Outgoing LW at the top of the atmosphere [W/m^2]. |
| [in] | heating_rate_max | Maximum heating rate magnitude [K/s]. |
| [in] | seb_residual_mean | [optional] Mean SEB residual [W/m^2]; if non-finite, not written. |
| [in] | seb_residual_max | [optional] Max SEB residual [W/m^2]; if non-finite, not written. |
| [in] | t_s_mean | [optional] Mean surface temperature [K]; if non-finite, written as NaN. |
| [in] | t_s_max | [optional] Max surface temperature [K]; if non-finite, written as NaN. |
| [in] | q_s_mean | [optional] Mean surface moisture [kg/kg]; if non-finite, written as NaN. |
| [in] | q_s_max | [optional] Max surface moisture [kg/kg]; if non-finite, written as NaN. |
Referenced by TwoStreamRadiation::advance().


|
private |
Write CSV header if file is new or doesn't exist.
Referenced by append().

|
private |
AMR level this instance reports for.
Referenced by append().
|
private |
Referenced by append().
|
private |
Referenced by append(), and write_header_if_needed().
|
private |
Referenced by append().
|
private |
Referenced by append(), and write_header_if_needed().
|
private |
Output CSV file path.
Referenced by append(), and write_header_if_needed().
|
private |
Referenced by append().
|
private |
Referenced by append().
|
private |
Referenced by append().
|
private |
Track whether CSV header was written.
Referenced by write_header_if_needed().
|
private |
Referenced by append().
|
private |
Guard against duplicate writes.
Referenced by append().
|
private |
Referenced by append().
|
private |
Debug verbosity level.
Referenced by append().