1 #ifndef ERF_RRTMGP_UTILS_H
2 #define ERF_RRTMGP_UTILS_H
4 #include "rrtmgp_const.h"
10 template<
class View1,
class View2,
class View3,
class View4,
class View5>
13 View2
const& cloud_fraction,
16 View5
const& cloud_mass)
18 const int ncol = mixing_ratio.extent(0);
19 const int nlay = mixing_ratio.extent(1);
20 Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>>({0, 0}, {ncol, nlay}),
21 KOKKOS_LAMBDA (
int icol,
int ilay)
27 if (cloud_fraction(icol,ilay) > 0) {
29 auto incloud_mixing_ratio = std::min(mixing_ratio(icol,ilay) /
30 std::max(0.0001, cloud_fraction(icol,ilay)), 0.005);
31 cloud_mass(icol,ilay) = incloud_mixing_ratio *
rho(icol,ilay) * dz(icol,ilay);
33 cloud_mass(icol,ilay) = 0;
39 template<
typename InT,
typename OutT,
typename T>
46 Kokkos::parallel_for(arr_out.size(), KOKKOS_LAMBDA(
int i)
48 arr_out(i) = std::min(std::max(arr_in(i), lower), upper);
53 template<
typename InT,
typename OutT,
typename T>
60 const int ex0 = (int) arr_out.extent(0);
61 const int ex1 = (int) arr_out.extent(1);
62 Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>>({0, 0}, {ex0, ex1}),
63 KOKKOS_LAMBDA (
int i,
int j)
65 arr_out(i, j) = std::min(std::max(arr_in(i, j), lower), upper);
79 template<
class View1,
class View2,
class View3,
class View4,
class View5>
87 const int ncol = (int)flux_up.extent(0);
88 const int nlay = (int)flux_up.extent(1)-1;
89 Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>>({0, 0}, {ncol, nlay}),
90 KOKKOS_LAMBDA (
int icol,
int ilay)
92 heating_rate(icol,ilay) = ( flux_up(icol,ilay+1) - flux_up(icol,ilay)
93 - flux_dn(icol,ilay+1) + flux_dn(icol,ilay) )
94 / ( -
rho(icol,ilay) * dz(icol,ilay) *
Cp_d );
111 return ( (nstep == 0) || (nstep % irad == 0) );
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:12
@ rho
Definition: ERF_Kessler.H:22
@ T
Definition: ERF_IndexDefines.H:110
Definition: ERF_RRTMGP_Interface.cpp:16
bool radiation_do(const int irad, const int nstep)
Definition: ERF_RRTMGP_Utils.H:101
void limit_to_bounds_2d(InT const &arr_in, T const lower, T const upper, OutT &arr_out)
Definition: ERF_RRTMGP_Utils.H:55
void mixing_ratio_to_cloud_mass(View1 const &mixing_ratio, View2 const &cloud_fraction, View3 const &rho, View4 const &dz, View5 const &cloud_mass)
Definition: ERF_RRTMGP_Utils.H:12
void compute_heating_rate(View1 const &flux_up, View2 const &flux_dn, View3 const &rho, View4 const &dz, View5 &heating_rate)
Definition: ERF_RRTMGP_Utils.H:81
void limit_to_bounds_1d(InT const &arr_in, T const lower, T const upper, OutT &arr_out)
Definition: ERF_RRTMGP_Utils.H:41