ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_RRTMGP_Interface.H
Go to the documentation of this file.
1 #ifndef ERF_RRTMGP_INTERFACE_H
2 #define ERF_RRTMGP_INTERFACE_H
3 
4 #include <Kokkos_Core.hpp>
5 
6 #include <AMReX_REAL.H>
7 
8 #include <rrtmgp_const.h>
9 #include <mo_gas_optics_rrtmgp.h>
10 #include <mo_cloud_optics.h>
11 #include <mo_fluxes_byband.h>
12 #include <mo_load_coefficients.h>
13 #include <mo_gas_concentrations.h>
14 #include <mo_gas_optics_rrtmgp.h>
15 #include <mo_cloud_optics.h>
16 #include <mo_rte_sw.h>
17 #include <mo_rte_lw.h>
18 #include <mo_load_cloud_coefficients.h>
19 
20 #include <ERF_RRTMGP_Utils.H>
21 
22 #include <ERF_Kokkos.H>
23 
24 template <typename T>
25 using view_t = Kokkos::View<T, layout_t, KokkosDefaultDevice>;
26 
27 using pool_t = conv::MemPoolSingleton<RealT, layout_t, KokkosDefaultDevice>;
28 
29 using gas_optics_t = GasOpticsRRTMGPK<RealT, layout_t, KokkosDefaultDevice>;
30 using cloud_optics_t = CloudOpticsK<RealT, layout_t, KokkosDefaultDevice>;
31 using gas_concs_t = GasConcsK<RealT, layout_t, KokkosDefaultDevice>;
32 using fluxes_t = FluxesBybandK<RealT, layout_t, KokkosDefaultDevice>;
33 using fluxes_broadband_t = FluxesBroadbandK<RealT, layout_t, KokkosDefaultDevice>;
34 using optical_props_t = OpticalPropsK<RealT, layout_t, KokkosDefaultDevice>;
35 using optical_props1_t = OpticalProps1sclK<RealT, layout_t, KokkosDefaultDevice>;
36 using optical_props2_t = OpticalProps2strK<RealT, layout_t, KokkosDefaultDevice>;
37 using source_func_t = SourceFuncLWK<RealT, layout_t, KokkosDefaultDevice>;
38 
39 namespace rrtmgp {
40 
41 extern std::unique_ptr<gas_optics_t> k_dist_sw_k;
42 extern std::unique_ptr<gas_optics_t> k_dist_lw_k;
43 
44 extern std::unique_ptr<cloud_optics_t> cloud_optics_sw_k;
45 extern std::unique_ptr<cloud_optics_t> cloud_optics_lw_k;
46 
47 extern bool initialized;
48 
50 get_cloud_optics_sw (const int ncol,
51  const int nlay,
52  cloud_optics_t& cloud_optics,
53  gas_optics_t& kdist,
54  real2d_k& lwp,
55  real2d_k& iwp,
56  real2d_k& rel,
57  real2d_k& rei);
58 
60 get_cloud_optics_lw (const int ncol,
61  const int nlay,
62  cloud_optics_t& cloud_optics,
63  gas_optics_t& kdist,
64  real2d_k& lwp,
65  real2d_k& iwp,
66  real2d_k& rel,
67  real2d_k& rei);
68 
70 get_subsampled_clouds (const int ncol,
71  const int nlay,
72  const int nbnd,
73  const int ngpt,
74  optical_props2_t& cloud_optics,
75  gas_optics_t& kdist,
76  real2d_k& cld,
77  real2d_k& p_lay,
78  const bool do_subcol_sampling);
79 
81 get_subsampled_clouds (const int ncol,
82  const int nlay,
83  const int nbnd,
84  const int ngpt,
85  optical_props1_t& cloud_optics,
86  gas_optics_t& kdist,
87  real2d_k& cld,
88  real2d_k& p_lay,
89  const bool do_subcol_sampling);
90 
91 void
92 rrtmgp_initialize (gas_concs_t& gas_concs,
93  const std::string& coefficients_file_sw, const std::string& coefficients_file_lw,
94  const std::string& cloud_optics_file_sw, const std::string& cloud_optics_file_lw,
95  const int& nvar);
96 
97 
98 void
100 
101 
102 void
103 compute_band_by_band_surface_albedos (const int ncol, const int nswbands,
104  real1d_k& sfc_alb_dir_vis, real1d_k& sfc_alb_dir_nir,
105  real1d_k& sfc_alb_dif_vis, real1d_k& sfc_alb_dif_nir,
106  real2d_k& sfc_alb_dir, real2d_k& sfc_alb_dif);
107 
108 
109 void
110 compute_broadband_surface_fluxes (const int ncol, const int kbot, const int nswbands,
111  real3d_k& sw_bnd_flux_dir , real3d_k& sw_bnd_flux_dif ,
112  real1d_k& sfc_flux_dir_vis, real1d_k& sfc_flux_dir_nir,
113  real1d_k& sfc_flux_dif_vis, real1d_k& sfc_flux_dif_nir);
114 
115 
116 void
117 rrtmgp_main (const int ncol, const int nlay,
118  real2d_k& p_lay, real2d_k& t_lay,
119  real2d_k& p_lev, real2d_k& t_lev,
120  gas_concs_t& gas_concs,
121  real2d_k& sfc_alb_dir, real2d_k& sfc_alb_dif, real1d_k& mu0,
122  real1d_k& t_sfc , real1d_k& sfc_emis , real1d_k& lw_src,
123  real2d_k& lwp , real2d_k& iwp ,
124  real2d_k& rel , real2d_k& rei , real2d_k& cldfrac,
125  real2d_k& sw_flux_up , real2d_k& sw_flux_dn , real2d_k& sw_flux_dn_dir,
126  real2d_k& lw_flux_up , real2d_k& lw_flux_dn ,
127  real2d_k& sw_clnclrsky_flux_up, real2d_k& sw_clnclrsky_flux_dn, real2d_k& sw_clnclrsky_flux_dn_dir,
128  real2d_k& sw_clrsky_flux_up , real2d_k& sw_clrsky_flux_dn , real2d_k& sw_clrsky_flux_dn_dir,
129  real2d_k& sw_clnsky_flux_up , real2d_k& sw_clnsky_flux_dn , real2d_k& sw_clnsky_flux_dn_dir,
130  real2d_k& lw_clnclrsky_flux_up, real2d_k& lw_clnclrsky_flux_dn,
131  real2d_k& lw_clrsky_flux_up , real2d_k& lw_clrsky_flux_dn ,
132  real2d_k& lw_clnsky_flux_up , real2d_k& lw_clnsky_flux_dn ,
133  real3d_k& sw_bnd_flux_up , real3d_k& sw_bnd_flux_dn , real3d_k& sw_bnd_flux_dn_dir,
134  real3d_k& lw_bnd_flux_up , real3d_k& lw_bnd_flux_dn,
135  const RealT tsi_scaling,
136  const bool do_subcol_sampling,
137  const bool extra_clnclrsky_diag = false, const bool extra_clnsky_diag = false);
138 
139 
140 void
141 rrtmgp_sw (const int ncol, const int nlay,
142  gas_optics_t& k_dist,
143  real2d_k& p_lay, real2d_k& t_lay,
144  real2d_k& p_lev, real2d_k& t_lev,
145  gas_concs_t& gas_concs,
146  real2d_k& sfc_alb_dir, real2d_k& sfc_alb_dif, real1d_k& mu0,
147  optical_props2_t& aerosol, optical_props2_t& clouds,
148  fluxes_t& fluxes,
149  fluxes_broadband_t& clnclrsky_fluxes,
150  fluxes_broadband_t& clrsky_fluxes,
151  fluxes_broadband_t& clnsky_fluxes,
152  const RealT tsi_scaling,
153  const bool extra_clnclrsky_diag,
154  const bool extra_clnsky_diag);
155 
156 
157 void
158 rrtmgp_lw (const int ncol, const int nlay,
159  gas_optics_t& k_dist,
160  real2d_k& p_lay, real2d_k& t_lay,
161  real2d_k& p_lev, real2d_k& t_lev,
162  real1d_k& t_sfc, real1d_k& sfc_emis, real1d_k& lw_src,
163  gas_concs_t& gas_concs,
164  optical_props1_t& aerosol, optical_props1_t& clouds,
165  fluxes_t& fluxes,
166  fluxes_broadband_t& clnclrsky_fluxes,
167  fluxes_broadband_t& clrsky_fluxes,
168  fluxes_broadband_t& clnsky_fluxes,
169  const bool extra_clnclrsky_diag,
170  const bool extra_clnsky_diag);
171 
172 
173 int3d_k
174 get_subcolumn_mask (const int ncol,
175  const int nlay,
176  const int ngpt,
177  real2d_k& cldf,
178  const int overlap_option,
179  int1d_k& seeds);
180 
181 
182 void
183 compute_cloud_area (int ncol,
184  int nlay,
185  int ngpt,
186  RealT pmin,
187  RealT pmax,
188  const real2d_k& pmid,
189  const real3d_k& cld_tau_gpt,
190  real1d_k& cld_area);
191 
192 
193 void
194 compute_aerocom_cloudtop (int ncol, int nlay,
195  const real2d_k& tmid , const real2d_k& pmid,
196  const real2d_k& p_del, const real2d_k& z_del,
197  const real2d_k& qc , const real2d_k& qi,
198  const real2d_k& rel , const real2d_k& rei,
199  const real2d_k& cldfrac_tot, const real2d_k& nc,
200  real1d_k& T_mid_at_cldtop , real1d_k& p_mid_at_cldtop,
201  real1d_k& cldfrac_ice_at_cldtop , real1d_k& cldfrac_liq_at_cldtop,
202  real1d_k& cldfrac_tot_at_cldtop , real1d_k& cdnc_at_cldtop,
203  real1d_k& eff_radius_qc_at_cldtop, real1d_k& eff_radius_qi_at_cldtop);
204 
208 
209 } // namespace rrtmgp
210 #endif
Real wavelength
Definition: ERF_InitCustomPert_MovingTerrain.H:5
Kokkos::View< RealT *, KokkosDefaultDevice > real1d_k
Definition: ERF_Kokkos.H:18
Kokkos::View< int *, KokkosDefaultDevice > int1d_k
Definition: ERF_Kokkos.H:21
amrex::Real RealT
Definition: ERF_Kokkos.H:13
Kokkos::View< RealT ***, layout_t, KokkosDefaultDevice > real3d_k
Definition: ERF_Kokkos.H:20
Kokkos::View< RealT **, layout_t, KokkosDefaultDevice > real2d_k
Definition: ERF_Kokkos.H:19
Kokkos::View< int ***, layout_t, KokkosDefaultDevice > int3d_k
Definition: ERF_Kokkos.H:23
FluxesBroadbandK< RealT, layout_t, KokkosDefaultDevice > fluxes_broadband_t
Definition: ERF_RRTMGP_Interface.H:33
OpticalProps1sclK< RealT, layout_t, KokkosDefaultDevice > optical_props1_t
Definition: ERF_RRTMGP_Interface.H:35
CloudOpticsK< RealT, layout_t, KokkosDefaultDevice > cloud_optics_t
Definition: ERF_RRTMGP_Interface.H:30
OpticalProps2strK< RealT, layout_t, KokkosDefaultDevice > optical_props2_t
Definition: ERF_RRTMGP_Interface.H:36
FluxesBybandK< RealT, layout_t, KokkosDefaultDevice > fluxes_t
Definition: ERF_RRTMGP_Interface.H:32
OpticalPropsK< RealT, layout_t, KokkosDefaultDevice > optical_props_t
Definition: ERF_RRTMGP_Interface.H:34
GasConcsK< RealT, layout_t, KokkosDefaultDevice > gas_concs_t
Definition: ERF_RRTMGP_Interface.H:31
GasOpticsRRTMGPK< RealT, layout_t, KokkosDefaultDevice > gas_optics_t
Definition: ERF_RRTMGP_Interface.H:29
Kokkos::View< T, layout_t, KokkosDefaultDevice > view_t
Definition: ERF_RRTMGP_Interface.H:25
SourceFuncLWK< RealT, layout_t, KokkosDefaultDevice > source_func_t
Definition: ERF_RRTMGP_Interface.H:37
conv::MemPoolSingleton< RealT, layout_t, KokkosDefaultDevice > pool_t
Definition: ERF_RRTMGP_Interface.H:27
@ nc
Definition: ERF_Morrison.H:47
@ qi
Definition: ERF_Morrison.H:111
@ qc
Definition: ERF_Morrison.H:110
Definition: ERF_RRTMGP_SurfaceTemperature.H:8
void rrtmgp_finalize()
Definition: ERF_RRTMGP_Interface.cpp:277
int get_wavelength_index_sw(RealT wavelength)
Definition: ERF_RRTMGP_Interface.cpp:1119
int get_wavelength_index_lw(RealT wavelength)
Definition: ERF_RRTMGP_Interface.cpp:1123
void compute_aerocom_cloudtop(int ncol, int nlay, const real2d_k &tmid, const real2d_k &pmid, const real2d_k &p_del, const real2d_k &z_del, const real2d_k &qc, const real2d_k &qi, const real2d_k &rel, const real2d_k &rei, const real2d_k &cldfrac_tot, const real2d_k &nc, real1d_k &T_mid_at_cldtop, real1d_k &p_mid_at_cldtop, real1d_k &cldfrac_ice_at_cldtop, real1d_k &cldfrac_liq_at_cldtop, real1d_k &cldfrac_tot_at_cldtop, real1d_k &cdnc_at_cldtop, real1d_k &eff_radius_qc_at_cldtop, real1d_k &eff_radius_qi_at_cldtop)
Definition: ERF_RRTMGP_Interface.cpp:1157
void rrtmgp_main(const int ncol, const int nlay, real2d_k &p_lay, real2d_k &t_lay, real2d_k &p_lev, real2d_k &t_lev, gas_concs_t &gas_concs, real2d_k &sfc_alb_dir, real2d_k &sfc_alb_dif, real1d_k &mu0, real1d_k &t_sfc, real1d_k &sfc_emis, real1d_k &lw_src, real2d_k &lwp, real2d_k &iwp, real2d_k &rel, real2d_k &rei, real2d_k &cldfrac, real2d_k &sw_flux_up, real2d_k &sw_flux_dn, real2d_k &sw_flux_dn_dir, real2d_k &lw_flux_up, real2d_k &lw_flux_dn, real2d_k &sw_clnclrsky_flux_up, real2d_k &sw_clnclrsky_flux_dn, real2d_k &sw_clnclrsky_flux_dn_dir, real2d_k &sw_clrsky_flux_up, real2d_k &sw_clrsky_flux_dn, real2d_k &sw_clrsky_flux_dn_dir, real2d_k &sw_clnsky_flux_up, real2d_k &sw_clnsky_flux_dn, real2d_k &sw_clnsky_flux_dn_dir, real2d_k &lw_clnclrsky_flux_up, real2d_k &lw_clnclrsky_flux_dn, real2d_k &lw_clrsky_flux_up, real2d_k &lw_clrsky_flux_dn, real2d_k &lw_clnsky_flux_up, real2d_k &lw_clnsky_flux_dn, real3d_k &sw_bnd_flux_up, real3d_k &sw_bnd_flux_dn, real3d_k &sw_bnd_flux_dn_dir, real3d_k &lw_bnd_flux_up, real3d_k &lw_bnd_flux_dn, const RealT tsi_scaling, const bool do_subcol_sampling, const bool extra_clnclrsky_diag, const bool extra_clnsky_diag)
Definition: ERF_RRTMGP_Interface.cpp:395
optical_props1_t get_cloud_optics_lw(const int ncol, const int nlay, cloud_optics_t &cloud_optics, gas_optics_t &kdist, real2d_k &lwp, real2d_k &iwp, real2d_k &rel, real2d_k &rei)
Definition: ERF_RRTMGP_Interface.cpp:68
void compute_band_by_band_surface_albedos(const int ncol, const int nswbands, real1d_k &sfc_alb_dir_vis, real1d_k &sfc_alb_dir_nir, real1d_k &sfc_alb_dif_vis, real1d_k &sfc_alb_dif_nir, real2d_k &sfc_alb_dir, real2d_k &sfc_alb_dif)
Definition: ERF_RRTMGP_Interface.cpp:293
void compute_broadband_surface_fluxes(const int ncol, const int kbot, const int nswbands, real3d_k &sw_bnd_flux_dir, real3d_k &sw_bnd_flux_dif, real1d_k &sfc_flux_dir_vis, real1d_k &sfc_flux_dir_nir, real1d_k &sfc_flux_dif_vis, real1d_k &sfc_flux_dif_nir)
Definition: ERF_RRTMGP_Interface.cpp:337
std::unique_ptr< gas_optics_t > k_dist_sw_k
Definition: ERF_RRTMGP_Interface.cpp:11
int get_wavelength_index(optical_props_t &kdist, RealT wavelength)
Definition: ERF_RRTMGP_Interface.cpp:1127
void rrtmgp_initialize(gas_concs_t &gas_concs_k, const std::string &coefficients_file_sw, const std::string &coefficients_file_lw, const std::string &cloud_optics_file_sw, const std::string &cloud_optics_file_lw, const int &nvar)
Definition: ERF_RRTMGP_Interface.cpp:237
optical_props2_t get_cloud_optics_sw(const int ncol, const int nlay, cloud_optics_t &cloud_optics, gas_optics_t &kdist, real2d_k &lwp, real2d_k &iwp, real2d_k &rel, real2d_k &rei)
Definition: ERF_RRTMGP_Interface.cpp:34
void rrtmgp_sw(const int ncol, const int nlay, gas_optics_t &k_dist, real2d_k &p_lay, real2d_k &t_lay, real2d_k &p_lev, real2d_k &t_lev, gas_concs_t &gas_concs, real2d_k &sfc_alb_dir, real2d_k &sfc_alb_dif, real1d_k &mu0, optical_props2_t &aerosol, optical_props2_t &clouds, fluxes_t &fluxes, fluxes_broadband_t &clnclrsky_fluxes, fluxes_broadband_t &clrsky_fluxes, fluxes_broadband_t &clnsky_fluxes, const RealT tsi_scaling, const bool extra_clnclrsky_diag, const bool extra_clnsky_diag)
Definition: ERF_RRTMGP_Interface.cpp:601
std::unique_ptr< gas_optics_t > k_dist_lw_k
Definition: ERF_RRTMGP_Interface.cpp:12
optical_props2_t get_subsampled_clouds(const int ncol, const int nlay, const int nbnd, const int ngpt, optical_props2_t &cloud_optics, gas_optics_t &kdist, real2d_k &cld, real2d_k &p_lay, const bool do_subcol_sampling)
Definition: ERF_RRTMGP_Interface.cpp:102
void rrtmgp_lw(const int ncol, const int nlay, gas_optics_t &k_dist, real2d_k &p_lay, real2d_k &t_lay, real2d_k &p_lev, real2d_k &t_lev, real1d_k &t_sfc, real1d_k &sfc_emis, [[maybe_unused]] real1d_k &lw_src, gas_concs_t &gas_concs, optical_props1_t &aerosol, optical_props1_t &clouds, fluxes_t &fluxes, fluxes_broadband_t &clnclrsky_fluxes, fluxes_broadband_t &clrsky_fluxes, fluxes_broadband_t &clnsky_fluxes, const bool extra_clnclrsky_diag, const bool extra_clnsky_diag)
Definition: ERF_RRTMGP_Interface.cpp:907
std::unique_ptr< cloud_optics_t > cloud_optics_sw_k
Definition: ERF_RRTMGP_Interface.cpp:19
int3d_k get_subcolumn_mask(const int ncol, const int nlay, const int ngpt, real2d_k &cldf, const int overlap_option, int1d_k &seeds)
Definition: ERF_RRTMGP_Interface.cpp:528
std::unique_ptr< cloud_optics_t > cloud_optics_lw_k
Definition: ERF_RRTMGP_Interface.cpp:20
bool initialized
Definition: ERF_RRTMGP_Interface.cpp:25
void compute_cloud_area(int ncol, int nlay, int ngpt, const RealT pmin, const RealT pmax, const real2d_k &pmid, const real3d_k &cld_tau_gpt, real1d_k &cld_area)
Definition: ERF_RRTMGP_Interface.cpp:1083