ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_RRTMGP_SurfaceTemperature.H
Go to the documentation of this file.
1 #ifndef ERF_RRTMGP_SURFACE_TEMPERATURE_H_
2 #define ERF_RRTMGP_SURFACE_TEMPERATURE_H_
3 
4 #include <ERF_Constants.H>
5 #include <ERF_EOS.H>
7 
8 namespace rrtmgp {
9 
10 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
12 inverse_exner (const amrex::Real pressure, const amrex::Real rdOcp)
13 {
14  return one / getExnergivenP(pressure, rdOcp);
15 }
16 
17 /**
18  * Resolve the RRTMGP surface-temperature input from ERF's surface sources.
19  *
20  * RRTMGP and LSM surface-temperature fields contain absolute temperature,
21  * while the SurfaceLayer field contains potential temperature. The latter
22  * must therefore be converted with the physical surface pressure diagnosed
23  * from the lowest atmospheric cell before it is handed to RRTMGP.
24  *
25  * @param[in] is_land true when the column is over land
26  * @param[in] has_lsm_t_sfc true when an LSM t_sfc field exists
27  * @param[in] valid_lsm_t_sfc true when the LSM value is not a sentinel
28  * @param[in] lsm_t_sfc LSM t_sfc value, when present
29  * @param[in] has_surface_layer true when a SurfaceLayer field exists
30  * @param[in] surface_layer_theta SurfaceLayer potential temperature
31  * @param[in] surface_pressure physical surface pressure diagnosed from
32  * the lowest atmospheric cell
33  * @param[in] rdOcp configured Rd/cp exponent
34  * @param[in] default_t_sfc configured absolute-temperature fallback
35  * @param[out] t_sfc resolved absolute temperature for RRTMGP
36  * @param[in,out] lsm_t_sfc_out optional LSM fallback/writeback field
37  */
38 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
39 void
40 resolve_surface_temperature (const bool is_land,
41  const bool has_lsm_t_sfc,
42  const bool valid_lsm_t_sfc,
43  const amrex::Real lsm_t_sfc,
44  const bool has_surface_layer,
45  const amrex::Real surface_layer_theta,
46  const amrex::Real surface_pressure,
47  const amrex::Real rdOcp,
48  const amrex::Real default_t_sfc,
49  amrex::Real& t_sfc,
50  amrex::Real* lsm_t_sfc_out)
51 {
52  // A valid land-model value is already absolute temperature. A valid LSM
53  // value over water follows the existing fallback chain instead.
54  const bool use_lsm_t_sfc = is_land && has_lsm_t_sfc && valid_lsm_t_sfc;
55 
56  if (use_lsm_t_sfc) {
57  t_sfc = lsm_t_sfc;
58  } else if (has_surface_layer &&
60  surface_layer_theta, surface_pressure, rdOcp, t_sfc)) {
61  // SurfaceLayer::get_t_surf() returns theta. RRTMGP requires T.
62  // The helper also rejects an invalid pressure or nonphysical theta.
63  } else {
64  t_sfc = default_t_sfc;
65  }
66 
67  // Preserve the existing fallback/writeback behavior, but write the value
68  // in the LSM contract: absolute temperature.
69  if (lsm_t_sfc_out != nullptr && !use_lsm_t_sfc) {
70  *lsm_t_sfc_out = t_sfc;
71  }
72 }
73 
74 } // namespace rrtmgp
75 
76 #endif
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenP(const amrex::Real P, const amrex::Real rdOcp)
Definition: ERF_EOS.H:141
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:72
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:30
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool theta_to_temperature(const amrex::Real theta, const amrex::Real pressure, const amrex::Real rdOcp, amrex::Real &temperature)
Definition: ERF_SurfaceTemperature.H:54
Definition: ERF_RRTMGP_SurfaceTemperature.H:8
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, amrex::Real *lsm_t_sfc_out)
Definition: ERF_RRTMGP_SurfaceTemperature.H:40
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