ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 #include <ERF_Constants.H>
22 
23 #include <ERF_Kokkos_Radiation.H>
24 
25 template <typename T>
26 using view_t = Kokkos::View<T, layout_t, RadDefaultDevice>;
27 
28 using pool_t = conv::MemPoolSingleton<RealT, layout_t, RadDefaultDevice>;
29 
30 using gas_optics_t = GasOpticsRRTMGPK<RealT, layout_t, RadDefaultDevice>;
31 using cloud_optics_t = CloudOpticsK<RealT, layout_t, RadDefaultDevice>;
32 using gas_concs_t = GasConcsK<RealT, layout_t, RadDefaultDevice>;
33 using fluxes_t = FluxesBybandK<RealT, layout_t, RadDefaultDevice>;
34 using fluxes_broadband_t = FluxesBroadbandK<RealT, layout_t, RadDefaultDevice>;
35 using optical_props_t = OpticalPropsK<RealT, layout_t, RadDefaultDevice>;
36 using optical_props1_t = OpticalProps1sclK<RealT, layout_t, RadDefaultDevice>;
37 using optical_props2_t = OpticalProps2strK<RealT, layout_t, RadDefaultDevice>;
38 using source_func_t = SourceFuncLWK<RealT, layout_t, RadDefaultDevice>;
39 
40 void init_kls ();
41 void finalize_kls ();
42 
43 namespace rrtmgp {
44 
45 extern std::unique_ptr<gas_optics_t> k_dist_sw_k;
46 extern std::unique_ptr<gas_optics_t> k_dist_lw_k;
47 
48 extern std::unique_ptr<cloud_optics_t> cloud_optics_sw_k;
49 extern std::unique_ptr<cloud_optics_t> cloud_optics_lw_k;
50 
51 extern bool initialized;
52 
54 get_cloud_optics_sw (const int ncol,
55  const int nlay,
56  cloud_optics_t& cloud_optics,
57  gas_optics_t& kdist,
58  real2d_k& lwp,
59  real2d_k& iwp,
60  real2d_k& rel,
61  real2d_k& rei);
62 
64 get_cloud_optics_lw (const int ncol,
65  const int nlay,
66  cloud_optics_t& cloud_optics,
67  gas_optics_t& kdist,
68  real2d_k& lwp,
69  real2d_k& iwp,
70  real2d_k& rel,
71  real2d_k& rei);
72 
74 get_subsampled_clouds (const int ncol,
75  const int nlay,
76  const int nbnd,
77  const int ngpt,
78  optical_props2_t& cloud_optics,
79  gas_optics_t& kdist,
80  real2d_k& cld,
81  real2d_k& p_lay);
82 
84 get_subsampled_clouds (const int ncol,
85  const int nlay,
86  const int nbnd,
87  const int ngpt,
88  optical_props1_t& cloud_optics,
89  gas_optics_t& kdist,
90  real2d_k& cld,
91  real2d_k& p_lay);
92 
93 void
94 rrtmgp_initialize (gas_concs_t& gas_concs,
95  const std::string& coefficients_file_sw, const std::string& coefficients_file_lw,
96  const std::string& cloud_optics_file_sw, const std::string& cloud_optics_file_lw);
97 
98 
99 void
100 rrtmgp_finalize ();
101 
102 
103 void
104 compute_band_by_band_surface_albedos (const int ncol, const int nswbands,
105  real1d_k& sfc_alb_dir_vis, real1d_k& sfc_alb_dir_nir,
106  real1d_k& sfc_alb_dif_vis, real1d_k& sfc_alb_dif_nir,
107  real2d_k& sfc_alb_dir, real2d_k& sfc_alb_dif);
108 
109 
110 void
111 compute_broadband_surface_fluxes (const int ncol, const int kbot, const int nswbands,
112  real3d_k& sw_bnd_flux_dir , real3d_k& sw_bnd_flux_dif ,
113  real1d_k& sfc_flux_dir_vis, real1d_k& sfc_flux_dir_nir,
114  real1d_k& sfc_flux_dif_vis, real1d_k& sfc_flux_dif_nir);
115 
116 
117 void
118 rrtmgp_main (const int ncol, const int nlay,
119  real2d_k& p_lay, real2d_k& t_lay,
120  real2d_k& p_lev, real2d_k& t_lev,
121  gas_concs_t& gas_concs,
122  real2d_k& sfc_alb_dir, real2d_k& sfc_alb_dif, real1d_k& mu0,
123  real1d_k& t_sfc , real2d_k& emis_sfc , real1d_k& lw_src,
124  real2d_k& lwp , real2d_k& iwp ,
125  real2d_k& rel , real2d_k& rei , real2d_k& cldfrac,
126  real3d_k& aer_tau_sw , real3d_k& aer_ssa_sw , real3d_k& aer_asm_sw,
127  real3d_k& aer_tau_lw ,
128  real3d_k& cld_tau_sw_bnd, real3d_k& cld_tau_lw_bnd,
129  real3d_k& cld_tau_sw_gpt, real3d_k& cld_tau_lw_gpt,
130  real2d_k& sw_flux_up , real2d_k& sw_flux_dn , real2d_k& sw_flux_dn_dir,
131  real2d_k& lw_flux_up , real2d_k& lw_flux_dn ,
132  real2d_k& sw_clnclrsky_flux_up, real2d_k& sw_clnclrsky_flux_dn, real2d_k& sw_clnclrsky_flux_dn_dir,
133  real2d_k& sw_clrsky_flux_up , real2d_k& sw_clrsky_flux_dn , real2d_k& sw_clrsky_flux_dn_dir,
134  real2d_k& sw_clnsky_flux_up , real2d_k& sw_clnsky_flux_dn , real2d_k& sw_clnsky_flux_dn_dir,
135  real2d_k& lw_clnclrsky_flux_up, real2d_k& lw_clnclrsky_flux_dn,
136  real2d_k& lw_clrsky_flux_up , real2d_k& lw_clrsky_flux_dn ,
137  real2d_k& lw_clnsky_flux_up , real2d_k& lw_clnsky_flux_dn ,
138  real3d_k& sw_bnd_flux_up , real3d_k& sw_bnd_flux_dn , real3d_k& sw_bnd_flux_dn_dir,
139  real3d_k& lw_bnd_flux_up , real3d_k& lw_bnd_flux_dn,
140  const RealT tsi_scaling,
141  const bool extra_clnclrsky_diag = false, const bool extra_clnsky_diag = false);
142 
143 
144 void
145 rrtmgp_sw (const int ncol, const int nlay,
146  gas_optics_t& k_dist,
147  real2d_k& p_lay, real2d_k& t_lay,
148  real2d_k& p_lev, real2d_k& t_lev,
149  gas_concs_t& gas_concs,
150  real2d_k& sfc_alb_dir, real2d_k& sfc_alb_dif, real1d_k& mu0,
151  optical_props2_t& aerosol, optical_props2_t& clouds,
152  fluxes_t& fluxes,
153  fluxes_broadband_t& clnclrsky_fluxes,
154  fluxes_broadband_t& clrsky_fluxes,
155  fluxes_broadband_t& clnsky_fluxes,
156  const RealT tsi_scaling,
157  const bool extra_clnclrsky_diag,
158  const bool extra_clnsky_diag);
159 
160 
161 void
162 rrtmgp_lw (const int ncol, const int nlay,
163  gas_optics_t& k_dist,
164  real2d_k& p_lay, real2d_k& t_lay,
165  real2d_k& p_lev, real2d_k& t_lev,
166  real1d_k& t_sfc, real2d_k& emis_sfc, real1d_k& lw_src,
167  gas_concs_t& gas_concs,
168  optical_props1_t& aerosol, optical_props1_t& clouds,
169  fluxes_t& fluxes,
170  fluxes_broadband_t& clnclrsky_fluxes,
171  fluxes_broadband_t& clrsky_fluxes,
172  fluxes_broadband_t& clnsky_fluxes,
173  const bool extra_clnclrsky_diag,
174  const bool extra_clnsky_diag);
175 
176 
177 int3d_k
178 get_subcolumn_mask (const int ncol,
179  const int nlay,
180  const int ngpt,
181  real2d_k& cldf,
182  const int overlap_option,
183  int1d_k& seeds);
184 
185 
186 void
187 compute_cloud_area (int ncol,
188  int nlay,
189  int ngpt,
190  RealT pmin,
191  RealT pmax,
192  const real2d_k& pmid,
193  const real3d_k& cld_tau_gpt,
194  real1d_k& cld_area);
195 
196 
197 void
198 compute_aerocom_cloudtop (int ncol, int nlay,
199  const real2d_k& tmid , const real2d_k& pmid,
200  const real2d_k& p_del, const real2d_k& z_del,
201  const real2d_k& qc , const real2d_k& qi,
202  const real2d_k& rel , const real2d_k& rei,
203  const real2d_k& cldfrac_tot, const real2d_k& nc,
204  real1d_k& T_mid_at_cldtop , real1d_k& p_mid_at_cldtop,
205  real1d_k& cldfrac_ice_at_cldtop , real1d_k& cldfrac_liq_at_cldtop,
206  real1d_k& cldfrac_tot_at_cldtop , real1d_k& cdnc_at_cldtop,
207  real1d_k& eff_radius_qc_at_cldtop, real1d_k& eff_radius_qi_at_cldtop);
208 
209 int get_wavelength_index (optical_props_t& kdist, RealT wavelength);
210 int get_wavelength_index_sw (RealT wavelength);
211 int get_wavelength_index_lw (RealT wavelength);
212 
213 } // namespace rrtmgp
214 #endif
Kokkos::View< int ***, layout_t, RadDefaultDevice > int3d_k
Definition: ERF_Kokkos_Radiation.H:22
Kokkos::View< RealT *, RadDefaultDevice > real1d_k
Definition: ERF_Kokkos_Radiation.H:17
amrex::Real RealT
Definition: ERF_Kokkos_Radiation.H:14
Kokkos::View< int *, RadDefaultDevice > int1d_k
Definition: ERF_Kokkos_Radiation.H:20
Kokkos::View< RealT ***, layout_t, RadDefaultDevice > real3d_k
Definition: ERF_Kokkos_Radiation.H:19
Kokkos::View< RealT **, layout_t, RadDefaultDevice > real2d_k
Definition: ERF_Kokkos_Radiation.H:18
SourceFuncLWK< RealT, layout_t, RadDefaultDevice > source_func_t
Definition: ERF_RRTMGP_Interface.H:38
OpticalProps2strK< RealT, layout_t, RadDefaultDevice > optical_props2_t
Definition: ERF_RRTMGP_Interface.H:37
OpticalProps1sclK< RealT, layout_t, RadDefaultDevice > optical_props1_t
Definition: ERF_RRTMGP_Interface.H:36
OpticalPropsK< RealT, layout_t, RadDefaultDevice > optical_props_t
Definition: ERF_RRTMGP_Interface.H:35
GasConcsK< RealT, layout_t, RadDefaultDevice > gas_concs_t
Definition: ERF_RRTMGP_Interface.H:32
CloudOpticsK< RealT, layout_t, RadDefaultDevice > cloud_optics_t
Definition: ERF_RRTMGP_Interface.H:31
GasOpticsRRTMGPK< RealT, layout_t, RadDefaultDevice > gas_optics_t
Definition: ERF_RRTMGP_Interface.H:30
Kokkos::View< T, layout_t, RadDefaultDevice > view_t
Definition: ERF_RRTMGP_Interface.H:26
void init_kls()
Definition: ERF_RRTMGP_Interface.cpp:3
conv::MemPoolSingleton< RealT, layout_t, RadDefaultDevice > pool_t
Definition: ERF_RRTMGP_Interface.H:28
void finalize_kls()
Definition: ERF_RRTMGP_Interface.cpp:9
FluxesBroadbandK< RealT, layout_t, RadDefaultDevice > fluxes_broadband_t
Definition: ERF_RRTMGP_Interface.H:34
FluxesBybandK< RealT, layout_t, RadDefaultDevice > fluxes_t
Definition: ERF_RRTMGP_Interface.H:33
@ nc
Definition: ERF_Morrison.H:44
@ qc
Definition: ERF_SatAdj.H:36
Definition: ERF_RRTMGP_Interface.cpp:16
void rrtmgp_finalize()
Definition: ERF_RRTMGP_Interface.cpp:279
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)
Definition: ERF_RRTMGP_Interface.cpp:242
int get_wavelength_index_sw(RealT wavelength)
Definition: ERF_RRTMGP_Interface.cpp:1109
int get_wavelength_index_lw(RealT wavelength)
Definition: ERF_RRTMGP_Interface.cpp:1113
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:1147
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:75
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:295
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:339
std::unique_ptr< gas_optics_t > k_dist_sw_k
Definition: ERF_RRTMGP_Interface.cpp:23
int get_wavelength_index(optical_props_t &kdist, RealT wavelength)
Definition: ERF_RRTMGP_Interface.cpp:1117
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:41
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:614
std::unique_ptr< gas_optics_t > k_dist_lw_k
Definition: ERF_RRTMGP_Interface.cpp:24
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, real2d_k &emis_sfc, 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:908
std::unique_ptr< cloud_optics_t > cloud_optics_sw_k
Definition: ERF_RRTMGP_Interface.cpp:31
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:541
std::unique_ptr< cloud_optics_t > cloud_optics_lw_k
Definition: ERF_RRTMGP_Interface.cpp:32
bool initialized
Definition: ERF_RRTMGP_Interface.cpp:37
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)
Definition: ERF_RRTMGP_Interface.cpp:109
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, real2d_k &emis_sfc, real1d_k &lw_src, real2d_k &lwp, real2d_k &iwp, real2d_k &rel, real2d_k &rei, real2d_k &cldfrac, real3d_k &aer_tau_sw, real3d_k &aer_ssa_sw, real3d_k &aer_asm_sw, real3d_k &aer_tau_lw, real3d_k &cld_tau_sw_bnd, real3d_k &cld_tau_lw_bnd, real3d_k &cld_tau_sw_gpt, real3d_k &cld_tau_lw_gpt, 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 extra_clnclrsky_diag, const bool extra_clnsky_diag)
Definition: ERF_RRTMGP_Interface.cpp:397
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:1072