ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SEBSkinInit.cpp File Reference
#include <limits>
#include <AMReX.H>
#include <AMReX_GpuContainers.H>
#include <AMReX_MFIter.H>
#include <AMReX_Reduce.H>
#include "ERF_SEBLandMask.H"
#include "ERF_SEBSkinInit.H"
Include dependency graph for ERF_SEBSkinInit.cpp:

Functions

SEBSkinInitReport seb_init_skin_from_file (MultiFab &t_sfc, const MultiFab &file_skin, const iMultiFab *land_mask, const Real t_lo, const Real t_hi)
 

Function Documentation

◆ seb_init_skin_from_file()

SEBSkinInitReport seb_init_skin_from_file ( MultiFab &  t_sfc,
const MultiFab &  file_skin,
const iMultiFab *  land_mask,
const Real  t_lo,
const Real  t_hi 
)
16 {
17  if (t_sfc.boxArray() != file_skin.boxArray() ||
18  t_sfc.DistributionMap() != file_skin.DistributionMap()) {
19  Abort("seb_init_skin_from_file: the file's skin temperature is not on the grids of "
20  "the balance's skin temperature");
21  }
22  seb_assert_land_mask_layout(land_mask, t_sfc, "seb_init_skin_from_file");
23 
24  // One pass: the copy and the counts. A refused column is left as it was, so the
25  // caller's message is the only effect of a bad value.
26  ReduceOps<ReduceOpSum, ReduceOpSum, ReduceOpMin, ReduceOpMax> reduce_op;
27  ReduceData<Long, Long, Real, Real> reduce_data(reduce_op);
28  using ReduceTuple = typename decltype(reduce_data)::Type;
29  const Real huge = std::numeric_limits<Real>::max();
30 
31  for (MFIter mfi(t_sfc, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
32  const Box& bx = mfi.tilebox();
33  const Array4<Real>& skin = t_sfc.array(mfi);
34  const Array4<const Real>& file = file_skin.const_array(mfi);
35  const SEBLandMaskView mask = seb_land_mask_view(land_mask, mfi);
36  reduce_op.eval(bx, reduce_data,
37  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept -> ReduceTuple
38  {
39  if (mask.water(i, j)) { return {Long(0), Long(0), huge, -huge}; }
40  const Real t = file(i, j, k);
41  if (!seb_skin_init_usable(t, t_lo, t_hi)) { return {Long(0), Long(1), huge, -huge}; }
42  skin(i, j, k) = t;
43  return {Long(1), Long(0), t, t};
44  });
45  }
46 
47  const ReduceTuple result = reduce_data.value(reduce_op);
48  SEBSkinInitReport report;
49  report.n_set = amrex::get<0>(result);
50  report.n_refused = amrex::get<1>(result);
51  report.t_min = amrex::get<2>(result);
52  report.t_max = amrex::get<3>(result);
53  return report;
54 }
SEBLandMaskView seb_land_mask_view(const amrex::iMultiFab *mask, const amrex::MFIter &mfi)
The view of mask on the box of mfi; off when mask is nullptr.
Definition: ERF_SEBLandMask.H:54
void seb_assert_land_mask_layout(const amrex::iMultiFab *mask, const amrex::FabArrayBase &field, const char *who)
Stop when mask is given and is not on the grids of field.
Definition: ERF_SEBLandMask.H:43
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool seb_skin_init_usable(const amrex::Real temperature, const amrex::Real t_lo, const amrex::Real t_hi) noexcept
True when temperature [K] can start the skin: finite and inside the range the balance holds the skin ...
Definition: ERF_SEBSkinInit.H:32
@ t
Definition: ERF_WSM6.H:295
The land mask of one box, for a device kernel. Captured by value.
Definition: ERF_SEBLandMask.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool water(int i, int j) const noexcept
True when the balance does not run on column (i, j).
Definition: ERF_SEBLandMask.H:35
What seb_init_skin_from_file did on the boxes of this rank.
Definition: ERF_SEBSkinInit.H:40
amrex::Real t_max
highest value set [K]; meaningful when n_set > 0
Definition: ERF_SEBSkinInit.H:44
amrex::Real t_min
lowest value set [K]; meaningful when n_set > 0
Definition: ERF_SEBSkinInit.H:43
amrex::Long n_set
land columns that took the file's value
Definition: ERF_SEBSkinInit.H:41
amrex::Long n_refused
land columns whose file value is not usable (left as they were)
Definition: ERF_SEBSkinInit.H:42

Referenced by ERF::init_seb_skin_from_file(), and ERF::init_seb_t_deep_from_file().

Here is the call graph for this function:
Here is the caller graph for this function: