ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Rrtmgp.H
Go to the documentation of this file.
1 /*
2  * RTE-RRTMGP radiation model interface to ERF
3  * The orgiinal code is developed by RobertPincus, and the code is open source available at:
4  * https://github.com/earth-system-radiation/rte-rrtmgp
5  * For details of the radiation algorithm, please reference to the following paper,
6  * https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2019MS001621
7  *
8  * NOTE: we use the C++ version of RTE-RRTMGP, which is reimplemented the original Fortran
9  * code using C++ YAKL for CUDA, HiP and SYCL application by E3SM ECP team, the C++ version
10  * of the rte-rrtmgp code is located at:
11  * https://github.com/E3SM-Project/rte-rrtmgp
12  *
13  * The RTE-RRTMGP uses BSD-3-Clause Open Source License, if you want to make changes,
14  * and modifications to the code, please refer to BSD-3-Clause Open Source License.
15  */
16 #ifndef ERF_RRTMGP_H
17 #define ERF_RRTMGP_H
18 
19 #include <string>
20 #include <vector>
21 #include <memory>
22 
23 #include <ERF_Constants.H>
24 
25 // rrtmgp includes
26 #include <mo_gas_concentrations.h>
27 #include <mo_gas_optics_rrtmgp.h>
28 #include <mo_load_coefficients.h>
29 #include <mo_rte_sw.h>
30 #include <mo_rte_lw.h>
31 #include <mo_optical_props.h>
32 #include <mo_fluxes_byband.h>
33 #include <rrtmgp_const.h>
34 
35 using yakl::fortran::parallel_for;
36 using yakl::fortran::SimpleBounds;
37 
38 // Radiation code interface class
39 class Rrtmgp {
40  public:
41  // constructor
42  Rrtmgp () = default;
43 
44  // deconstructor
45  ~Rrtmgp () = default;
46 
47  // initialize and load gas property data for rrtmgp radiation
48  void initialize (int num_gas, const std::vector<std::string>& active_gas_names,
49  const char* rrtmgp_coefficients_file_sw,
50  const char* rrtmgp_coefficients_file_lw);
51 
52  // finalize/clean up
53  void finalize ();
54 
55  // run rrtmgp short wave model
56  void run_shortwave_rrtmgp (int ngas, int ncol, int nlay,
57  const real3d& gas_vmr, const real2d& pmid, const real2d& tmid, const real2d& pint,
58  const real1d& coszrs , const real2d& albedo_dir, const real2d& albedo_dif,
59  const real3d& cld_tau_gpt, const real3d& cld_ssa_gpt, const real3d& cld_asm_gpt,
60  const real3d& aer_tau_bnd, const real3d& aer_ssa_bnd, const real3d& aer_asm_bnd,
61  const real2d& allsky_flux_up , const real2d& allsky_flux_dn , const real2d& allsky_flux_net , const real2d& allsky_flux_dn_dir,
62  const real3d& allsky_bnd_flux_up, const real3d& allsky_bnd_flux_dn, const real3d& allsky_bnd_flux_net, const real3d& allsky_bnd_flux_dn_dir,
63  const real2d& clrsky_flux_up , const real2d& clrsky_flux_dn , const real2d& clrsky_flux_net , const real2d& clrsky_flux_dn_dir,
64  const real3d& clrsky_bnd_flux_up, const real3d& clrsky_bnd_flux_dn, const real3d& clrsky_bnd_flux_net, const real3d& clrsky_bnd_flux_dn_dir,
65  double tsi_scaling);
66 
67  // run rrtmgp long wave model
68  void run_longwave_rrtmgp (int ngas, int ncol, int nlay, const real3d& gas_vmr,
69  const real2d& pmid, const real2d& tmid, const real2d& pint , const real2d& tint,
70  const real2d& emis_sfc,
71  const real3d& cld_tau_gpt , const real3d& aer_tau_bnd ,
72  const real2d& allsky_flux_up , const real2d& allsky_flux_dn , const real2d& allsky_flux_net ,
73  const real3d& allsky_bnd_flux_up, const real3d& allsky_bnd_flux_dn, const real3d& allsky_bnd_flux_net,
74  const real2d& clrsky_flux_up , const real2d& clrsky_flux_dn , const real2d& clrsky_flux_net ,
75  const real3d& clrsky_bnd_flux_up, const real3d& clrsky_bnd_flux_dn, const real3d& clrsky_bnd_flux_net);
76 
77  int get_nband_sw () {
78  return k_dist_sw.get_nband();
79  }
80 
81  int get_nband_lw () {
82  return k_dist_lw.get_nband();
83  }
84 
85  int get_ngpt_sw () {
86  return k_dist_sw.get_ngpt();
87  }
88 
89  int get_ngpt_lw () {
90  return k_dist_lw.get_ngpt();
91  }
92 
93  double get_min_temperature () {
94  return std::min(k_dist_sw.temp_ref_min, k_dist_lw.temp_ref_min);
95  }
96 
97  double get_max_temperature () {
98  return std::max(k_dist_sw.temp_ref_max, k_dist_lw.temp_ref_max);
99  }
100 
101  void get_gpoint_bands_sw (int1d& gpoint_bands) {
102  gpoint_bands = k_dist_sw.get_gpoint_bands();
103  yakl::fence();
104  }
105 
106  void get_gpoint_bands_lw (int1d& gpoint_bands) {
107  gpoint_bands = k_dist_lw.get_gpoint_bands();
108  yakl::fence();
109  }
110 
111  private:
112  // number of gas for radiation model
113  int ngas;
114  string1d active_gases;
115 
116  // coefficient files
117  char const *coefficients_file_sw; // short wave gas optics coefficient files
118  char const *coefficients_file_lw; // long wave gas optics coefficient files
119 
120  // Objects for gas optics data
121  GasOpticsRRTMGP k_dist_sw;
122  GasOpticsRRTMGP k_dist_lw;
123 };
124 
125 #endif // ERF_RRTMGP_H
Definition: ERF_Rrtmgp.H:39
char const * coefficients_file_lw
Definition: ERF_Rrtmgp.H:118
string1d active_gases
Definition: ERF_Rrtmgp.H:114
void run_shortwave_rrtmgp(int ngas, int ncol, int nlay, const real3d &gas_vmr, const real2d &pmid, const real2d &tmid, const real2d &pint, const real1d &coszrs, const real2d &albedo_dir, const real2d &albedo_dif, const real3d &cld_tau_gpt, const real3d &cld_ssa_gpt, const real3d &cld_asm_gpt, const real3d &aer_tau_bnd, const real3d &aer_ssa_bnd, const real3d &aer_asm_bnd, const real2d &allsky_flux_up, const real2d &allsky_flux_dn, const real2d &allsky_flux_net, const real2d &allsky_flux_dn_dir, const real3d &allsky_bnd_flux_up, const real3d &allsky_bnd_flux_dn, const real3d &allsky_bnd_flux_net, const real3d &allsky_bnd_flux_dn_dir, const real2d &clrsky_flux_up, const real2d &clrsky_flux_dn, const real2d &clrsky_flux_net, const real2d &clrsky_flux_dn_dir, const real3d &clrsky_bnd_flux_up, const real3d &clrsky_bnd_flux_dn, const real3d &clrsky_bnd_flux_net, const real3d &clrsky_bnd_flux_dn_dir, double tsi_scaling)
Definition: ERF_Run_shortwave_rrtmgp.cpp:4
int get_ngpt_lw()
Definition: ERF_Rrtmgp.H:89
void get_gpoint_bands_lw(int1d &gpoint_bands)
Definition: ERF_Rrtmgp.H:106
int get_nband_sw()
Definition: ERF_Rrtmgp.H:77
void run_longwave_rrtmgp(int ngas, int ncol, int nlay, const real3d &gas_vmr, const real2d &pmid, const real2d &tmid, const real2d &pint, const real2d &tint, const real2d &emis_sfc, const real3d &cld_tau_gpt, const real3d &aer_tau_bnd, const real2d &allsky_flux_up, const real2d &allsky_flux_dn, const real2d &allsky_flux_net, const real3d &allsky_bnd_flux_up, const real3d &allsky_bnd_flux_dn, const real3d &allsky_bnd_flux_net, const real2d &clrsky_flux_up, const real2d &clrsky_flux_dn, const real2d &clrsky_flux_net, const real3d &clrsky_bnd_flux_up, const real3d &clrsky_bnd_flux_dn, const real3d &clrsky_bnd_flux_net)
Definition: ERF_Run_longwave_rrtmgp.cpp:10
int ngas
Definition: ERF_Rrtmgp.H:113
double get_max_temperature()
Definition: ERF_Rrtmgp.H:97
char const * coefficients_file_sw
Definition: ERF_Rrtmgp.H:117
int get_nband_lw()
Definition: ERF_Rrtmgp.H:81
int get_ngpt_sw()
Definition: ERF_Rrtmgp.H:85
void get_gpoint_bands_sw(int1d &gpoint_bands)
Definition: ERF_Rrtmgp.H:101
void initialize(int num_gas, const std::vector< std::string > &active_gas_names, const char *rrtmgp_coefficients_file_sw, const char *rrtmgp_coefficients_file_lw)
Definition: ERF_Init_rrtmgp.cpp:13
GasOpticsRRTMGP k_dist_lw
Definition: ERF_Rrtmgp.H:122
double get_min_temperature()
Definition: ERF_Rrtmgp.H:93
GasOpticsRRTMGP k_dist_sw
Definition: ERF_Rrtmgp.H:121
~Rrtmgp()=default
void finalize()
Definition: ERF_Finalize_rrtmgp.cpp:13
Rrtmgp()=default