ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_NOAHMP.H
Go to the documentation of this file.
1 #ifndef NOAHMP_H
2 #define NOAHMP_H
3 
4 #include <string>
5 #include <vector>
6 #include <memory>
7 #include <limits>
8 #include <functional>
9 
10 #include <AMReX_ParmParse.H>
11 #include <AMReX_Interpolater.H>
12 #include <AMReX_FillPatchUtil.H>
13 #include <AMReX_FArrayBox.H>
14 #include <AMReX_Geometry.H>
15 #include <AMReX_MultiFabUtil.H>
16 #include <AMReX_Vector.H>
17 #include <AMReX_MFIter.H>
18 #include <AMReX_VisMF.H>
19 #include <AMReX_Utility.H>
20 
21 #include <ERF_NullSurf.H>
22 #include <ERF_NumericalConstants.H>
23 #include <ERF_IndexDefines.H>
24 #include <ERF_DataStruct.H>
26 
27 #include <NoahmpIO.H>
28 #include <ERF_NOAHMP_Fields.H>
29 
30 // Small POD helpers used by the Advance_With_State
31 namespace erf_noahmp {
32  // Typed precip accumulator views collected once per Advance: per slot, the
33  // borrowed native accumulator, its native->kg/m^2 factor, and whether it is filled.
34  struct PrecipSlots {
35  const amrex::MultiFab* accum [NoahmpPrecipSlot::NumSlots] = {};
38  bool have_any = false;
39  };
40 
41  // Cells the precip guard clamped this call (per rank); reported after the box loop.
42  struct ClampedPrecipCell { int i; int j; amrex::Real raw_mm; };
43 
44  // Cells where frozen components violated MP_SNOW+MP_GRAUP <= MP_RAINNC and were
45  // rescaled (per rank); reported after the loop.
46  struct InvariantPrecipCell { int i; int j; amrex::Real froz_mm; amrex::Real total_mm; };
47 
48  // Per-surface-box handles co-indexed by idb: the NoahmpIO block plus its
49  // pinned input/output staging buffers.
51  NoahmpIO_type* io; // &noahmpio_vect[idb]
52  amrex::Array4<amrex::Real> input; // noahmp_input_tmp[idb]->array()
53  amrex::Array4<amrex::Real> output; // noahmp_output_tmp[idb]->array()
54  };
55 }
56 
57 class NOAHMP : public NullSurf {
58 
59  using FabPtr = std::shared_ptr<amrex::MultiFab>;
60 
61 public:
62  // Bring the base-class Init overloads into scope so the single override below
63  // does not hide them (-Woverloaded-virtual), matching SLM.
64  using NullSurf::Init;
65 
66  // Constructor
67  NOAHMP () {}
68 
69  // Destructor
70  virtual ~NOAHMP () = default;
71 
72  // Set thermo and grid properties
73  void
74  Define (SolverChoice& sc) override
75  {
76  // Whether the configured radiation model writes Noah-MP's radiation inputs
77  // (SWDOWN, GLW, COSZEN); see the first-land-step check in Advance_With_State.
79  m_radiation_model_name = amrex::getEnumNameString(sc.rad_type);
80  // A run initialized from WRF or metgrid files names a finer level's file with
81  // erf.nc_init_file_<lev>; an idealized one has none (see Init).
82  m_idealized_init = (sc.init_type != InitType::WRFInput &&
83  sc.init_type != InitType::Metgrid);
84  }
85 
86  // Whether this level runs the Noah-MP driver on a land setup file of its own (level 0
87  // always does), as opposed to taking its land state from level 0 (interp_from_lev0).
88  // Set in Init.
89  [[nodiscard]] bool
90  Runs_Own_Land_Driver () const override { return m_has_nc_file; }
91 
92  // Initialize data structures
93  void
94  Init (const int& lev,
95  const amrex::MultiFab& cons_in,
96  const amrex::Geometry& geom,
97  const amrex::Geometry& geom0,
98  amrex::Vector<amrex::BCRec>& domain_bcs_type,
99  amrex::IntVect& refRatio,
100  const amrex::Real& dt,
101  amrex::Vector<amrex::Vector<std::string>>& nc_init_file) override;
102 
103  // Wrapper to do all the updating
104  void
105  Advance_With_State (const int& lev,
106  amrex::MultiFab& cons_in,
107  amrex::MultiFab& xvel_in,
108  amrex::MultiFab& yvel_in,
109  amrex::MultiFab* hfx3_out,
110  amrex::MultiFab* qfx3_out,
111  const SurfacePrecipAccumulationSources& precip_sources,
112  const amrex::Real& elapsed_time,
113  const amrex::Real& dt,
114  const int& nstep,
115  const bool updated_lev0,
116  amrex::MultiFab* z_nd) override;
117 
118  void
119  Plot_Landfile (const int& nstep) override;
120 
121  // Get state vars from lsm class
122  amrex::MultiFab*
123  Lsm_Data_Ptr (const int& varIdx) override
124  {
125  int lsmIdx = LsmDataMap[varIdx];
126  AMREX_ALWAYS_ASSERT(lsmIdx < NOAHMP::m_lsm_data_size && lsmIdx>=0);
127  return lsm_fab_data[lsmIdx].get();
128  }
129 
130  // Get flux vars from lsm class
131  amrex::MultiFab*
132  Lsm_Flux_Ptr (const int& varIdx) override
133  {
134  int lsmIdx = LsmFluxMap[varIdx];
135  AMREX_ALWAYS_ASSERT(lsmIdx < NOAHMP::m_lsm_flux_size && lsmIdx>=0);
136  return lsm_fab_flux[lsmIdx].get();
137  }
138 
139  // Get lsm geometry
140  amrex::Geometry
141  Lsm_Geom ( ) override { return m_lsm_geom; }
142 
143  // Get number of vars. Parent queries this before Init (to size lsm_data), so
144  // resolve the soil-layer count here on first use rather than relying on Init.
145  int
147 
148  // Get number of fluxes lsm class contains
149  int
150  Lsm_Flux_Size () override { return NOAHMP::m_lsm_flux_size; }
151 
152  // Get variable names
153  std::string
154  Lsm_DataName (const int& varIdx) override
155  {
156  int lsmIdx = LsmDataMap[varIdx];
157  AMREX_ALWAYS_ASSERT(lsmIdx < NOAHMP::m_lsm_data_size && lsmIdx>=0);
158  return LsmDataName[lsmIdx];
159  }
160 
161  // Get variable index from name
162  int
163  Lsm_DataIndex (const std::string& varname) override
164  {
165  int varIdx = -1;
166  std::string lc_varname = amrex::toLower(varname);
167  for (int idx(0); idx<m_lsm_data_size; ++idx) {
168  if (lc_varname == amrex::toLower(LsmDataName[idx])) {
169  varIdx = idx;
170  }
171  }
172  return varIdx;
173  }
174 
175  // Get flux variable names
176  std::string
177  Lsm_FluxName (const int& varIdx) override
178  {
179  int lsmIdx = LsmFluxMap[varIdx];
180  AMREX_ALWAYS_ASSERT(lsmIdx < NOAHMP::m_lsm_flux_size && lsmIdx>=0);
181  return LsmFluxName[lsmIdx];
182  }
183 
184  // Get flux variable index from name
185  int
186  Lsm_FluxIndex (const std::string& varname) override
187  {
188  int varIdx = -1;
189  std::string lc_varname = amrex::toLower(varname);
190  for (int idx(0); idx<LsmFlux_NOAHMP::NumVars; ++idx) {
191  if (lc_varname == amrex::toLower(LsmFluxName[idx])) {
192  varIdx = idx;
193  }
194  }
195  return varIdx; // -1 if this model does not carry that flux; callers probe with this
196  }
197 
198  void
199  Lsm_Set_Lev0_Data_Ptr (const int& varIdx,
200  amrex::MultiFab* lev0_data_ptr) override
201  {
202  AMREX_ALWAYS_ASSERT(varIdx >= 0 && varIdx < m_lsm_data_size);
203  lsm_lev0_data[varIdx] = lev0_data_ptr;
204  m_interp_pending = true;
205  }
206 
207  void
208  Lsm_Set_Lev0_Flux_Ptr (const int& varIdx,
209  amrex::MultiFab* lev0_flux_ptr) override
210  {
211  AMREX_ALWAYS_ASSERT(varIdx >= 0 && varIdx < int(LsmFlux_NOAHMP::NumVars));
212  lsm_lev0_flux[varIdx] = lev0_flux_ptr;
213  m_interp_pending = true;
214  }
215 
216  bool
217  Get_Update_Status () override { return m_updated; }
218 
219  // Checkpoint/restore the NoahMP substep counter via m_itimestep (valid on every
220  // rank, unlike noahmpio_vect[0] which is absent on land-free ranks).
221  int
222  Get_LSM_Step () const override
223  {
224  return m_itimestep;
225  }
226 
227  void
228  Set_LSM_Step (int step) override
229  {
230  m_itimestep = step;
231  for (auto& noahmpio : noahmpio_vect) {
232  noahmpio.itimestep = step;
233  }
234  }
235 
236  // Write/read the full NoahMP prognostic state to/from a NetCDF restart dir so a
237  // restart reproduces a cold-start trajectory bitwise (#3255). ERF_NOAHMP_IO.cpp.
238  void
239  Write_Lsm_Restart (const std::string& dir) const override;
240 
241  void
242  Read_Lsm_Restart (const std::string& dir) override;
243 
244  // --- Advance_With_State pipeline helpers (ERF_NOAHMP_Advance.cpp) ---------
245 
246  // Fine-level (lev>0) coupling data/flux fill by interpolation from level 0,
247  // taken when there is no per-level NetCDF land file, on the steps level 0's
248  // driver fires (see Advance_With_State). Sets m_updated.
249  void
250  interp_from_lev0 (const int& lev,
251  amrex::MultiFab& cons_in,
252  const int& nstep);
253 
254  // Subcycling gate: true if the model fires this ERF step (sets m_updated). The
255  // lockstep counter is retired after the block loop, not here. Same on every rank.
256  bool
257  time_to_fire (const amrex::Real& elapsed_time);
258 
259  // Per surface box: stage ERF forcing into the pinned input buffer and copy into
260  // the NoahmpIO arrays (steps 1-3). blk bundles the block + its staging buffers.
261  void
262  stage_forcing (const amrex::MFIter& mfi,
263  const erf_noahmp::NoahmpBlockViews& blk,
264  const amrex::Box& bx,
265  const int& klo,
266  const int& lev,
267  const bool is_moist,
268  amrex::MultiFab& cons_in,
269  amrex::MultiFab& xvel_in,
270  amrex::MultiFab& yvel_in,
271  amrex::MultiFab* z_nd,
273  amrex::Vector<erf_noahmp::ClampedPrecipCell>& clamped_cells,
274  amrex::Vector<erf_noahmp::InvariantPrecipCell>& invariant_cells);
275 
276  // Per surface box: read NoahmpIO results into the pinned output buffer and scatter
277  // them into the ERF coupling fields (steps 5-6), applying the -9999 fill guard.
278  void
279  read_results (const amrex::MFIter& mfi,
280  const erf_noahmp::NoahmpBlockViews& blk,
281  const amrex::Box& bx,
282  const amrex::Box& gbx,
283  amrex::MultiFab& cons_in);
284 
285  // --- Precip bookkeeping (ERF_NOAHMP_Precip.cpp) --------------------------
286 
287  // Collect the typed precip accumulator views for this Advance.
290 
291  // Lazily allocate + seed the per-level "previous cumulative accum" snapshots
292  // (cold start seeds from current; restart consumes m_precip_accum_restored).
293  void
294  prepare_precip_snapshots (const int& lev,
296 
297  // Advance the snapshots to the current accumulation after the land call.
298  void
299  advance_precip_snapshots (const int& lev,
301 
302  // Report (per rank, never silent) any cells clamped or rescaled by the guard.
303  void
304  report_precip_diagnostics (const int& lev,
305  const amrex::Vector<erf_noahmp::ClampedPrecipCell>& clamped_cells,
306  const amrex::Vector<erf_noahmp::InvariantPrecipCell>& invariant_cells);
307 
308  // 3 soil variable groups: smois, sh2o, tslb. All 3*nsoil buffer-size occurrences use this.
309  static constexpr int m_num_soil_groups = 3;
310 
311  // Index of soil field (g in {0:smois,1:sh2o,2:tslb}, k in [0,nsoil)) within
312  // lsm_fab_data. Output-buffer index is NoahmpOutputComp::NumComps + g*m_nsoil + k.
313  int soil_data_idx (int g, int k) const {
314  return LsmData_NOAHMP::NumVars + g*m_nsoil + k;
315  }
316 
317  // Resolve the soil-layer count and total LSM data size exactly once, before Init
318  // (the parent queries Lsm_Data_Size() first). Init later asserts vs namelist NSOIL.
319  bool m_nsoil_resolved = false;
321  if (m_nsoil_resolved) { return; }
322  amrex::ParmParse pp_nsoil("erf");
323  pp_nsoil.queryAdd("lsm_nsoil", m_nsoil);
324  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_nsoil >= 1, "erf.lsm_nsoil must be >= 1");
326  m_nsoil_resolved = true;
327  }
328 
329  // VisMF file prefix for the level-l, slot-s previous-accumulation snapshot.
330  static std::string
331  m_precip_snapshot_name (const std::string& dir, int l, int s) {
332  return dir + "/precip_accum_prev_Level_" + std::to_string(l)
333  + "_slot_" + std::to_string(s);
334  }
335 
336 private:
337 
338  // Runs fn(noahmpio) per local block on a land-owning MPI subcommunicator, so a
339  // rank with zero local boxes doesn't join the collective nf90_create in
340  // WriteLand/WriteRestart/ReadRestart. ERF_NOAHMP_IO.cpp.
341  void with_land_comm (const std::function<void(NoahmpIO_type&)>& fn) const;
342 
343  // lsm data var count = fixed 2D fields + runtime soil profile (3 x m_nsoil).
344  // Finalized once m_nsoil is known; the fixed-field count is a safe lower bound.
346 
347  // number of lsm flux variables
349 
350  // LsmData map (state indices -> LsmVar enum)
351  amrex::Vector<int> LsmDataMap;
352 
353  // LsmFlux map (state indices -> LsmFlux enum)
354  amrex::Vector<int> LsmFluxMap;
355 
356  // Lsm data names
357  amrex::Vector<std::string> LsmDataName;
358 
359  // Lsm flux names
360  amrex::Vector<std::string> LsmFluxName;
361 
362  // geometry for atmosphere
363  amrex::Geometry m_geom;
364 
365  // geometry for atmosphere at lev==0
366  amrex::Geometry m_geom0;
367 
368  // geometry for lsm
369  amrex::Geometry m_lsm_geom;
370 
371  // refinement ratio between lev==0 and this level (the product across every
372  // interface beneath it), since interp_from_lev0 interpolates from m_geom0
373  amrex::IntVect m_refRatio;
374 
375  // domain bc types
376  amrex::Vector<amrex::BCRec> m_domain_bcs_type;
377 
378 
379  // Authoritative NoahMP substep counter, kept on the class so the firing decision
380  // is identical on every rank (including land-free ranks with empty noahmpio_vect).
381  int m_itimestep = 0;
382 
383  // NoahMP timestep (DTBL), broadcast to all ranks in Init so the firing
384  // decision is well-defined on land-free ranks too.
385  amrex::Real m_dtbl = std::numeric_limits<amrex::Real>::max();
386 
387  // Default -1; not written at runtime (single-slab LSM has no z extent to track).
388  int khi_lsm = -1;
389 
390  // Number of grid points in z
391  int m_nz_lsm = 1;
392 
393  // Size of grid spacing in z
394  amrex::Real m_dz_lsm = one;
395 
396  // LSM data variables, sized at runtime to NumVars + 3*m_nsoil (fixed 2D fields +
397  // the SMOIS/SH2O/TSLB soil profile). Vector, since m_nsoil is only known in Init.
398  amrex::Vector<FabPtr> lsm_fab_data;
399 
400  // LSM flux variables
401  amrex::Array<FabPtr, LsmFlux_NOAHMP::NumVars> lsm_fab_flux;
402 
403  // LSM data variables at level 0 (runtime-sized, see lsm_fab_data)
404  amrex::Vector<amrex::MultiFab*> lsm_lev0_data;
405 
406  // LSM flux variables at level 0
407  amrex::Array<amrex::MultiFab*, LsmFlux_NOAHMP::NumVars> lsm_lev0_flux {};
408 
409  // Number of Noah-MP soil layers, set from erf.lsm_nsoil (identical on every rank,
410  // so no broadcast needed for the collective writes). Asserted vs namelist NSOIL.
411  int m_nsoil = 4;
412 
413  // Vector to store NoahmpIO objects at a level
414  NoahmpIO_vector noahmpio_vect;
415 
416  // Pinned memory buffers for host/device coupling to Noah-MP
417  amrex::Vector<std::unique_ptr<amrex::FArrayBox>> noahmp_input_tmp;
418  amrex::Vector<std::unique_ptr<amrex::FArrayBox>> noahmp_output_tmp;
419 
420  // Previous cumulative precip accumulator (native units) per slot per level;
421  // interval precip is (current - this) * native_to_kg_m2. Only provided slots exist.
422  amrex::Vector<amrex::Array<std::unique_ptr<amrex::MultiFab>, NoahmpPrecipSlot::NumSlots>>
424 
425  // Checkpointed previous-accumulation snapshots staged by Read_Lsm_Restart, consumed
426  // (reset) by the first Advance. Empty on a cold start or legacy checkpoint.
427  amrex::Array<std::unique_ptr<amrex::MultiFab>, NoahmpPrecipSlot::NumSlots> m_precip_accum_restored;
428 
429  // This instance's AMR level (set in Init); keys the per-level snapshot filenames.
430  int m_lev = 0;
431 
432  // Update status
433  bool m_updated = false;
434 
435  // A level without a land file of its own interpolates from level 0 only when level 0
436  // has fired since (m_interp_nstep is the level-0 step of the last interpolation), or
437  // when its fields or level-0 pointers have been rebuilt since (m_interp_pending).
438  bool m_interp_pending = true;
439  int m_interp_nstep = -1;
440 
441  // Does this level run the driver on a land setup file of its own? (See Init.)
442  bool m_has_nc_file = false;
443 
444  // Not initialized from WRF or metgrid files (set in Define).
445  bool m_idealized_init = false;
446 
447  // Set once a land step has seen valid radiation inputs (or warned that a model
448  // that never writes them is in use), so the check in Advance_With_State (a global
449  // reduction) stops running. Reset by Init: a rebuilt level (regrid, including the
450  // one a restart can trigger) re-installs the lsm_undefined sentinel, so a verdict
451  // from before the wipe no longer holds.
453 
454  // Set when the missing-radiation-inputs warning for a restarted/rebuilt level has
455  // been printed, so re-checking on later land steps does not repeat it.
457 
458  // The ERF step of the first Advance_With_State call since this level was last
459  // (re)built: 0 only on a run started from scratch, positive after a restart or a
460  // mid-run regrid (Init resets it to -1 when it re-installs the sentinel).
461  // Distinguishes "RRTMGP has certainly computed since the fields were initialized"
462  // (a fresh run computes radiation on step 0, before any land step) from "RRTMGP
463  // may not have recomputed yet" (after a restart or regrid it recomputes only on
464  // its rad_freq_in_steps schedule). Set by Advance_With_State.
466 
467  // True when the configured radiation model writes the radiation inputs (RRTMGP, or
468  // TwoStream), so an input still missing on the first land step is a broken coupling,
469  // not a configuration without radiation. Set in Define, with the model's name for the
470  // messages.
471  bool m_radiation_feeds_lsm = false;
473 };
474 #endif
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
const int klo
Definition: ERF_InitCustomPert_KE.H:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int idx(int i, int j, int k, int nx, int ny)
Definition: ERF_InitForEnsemble.cpp:404
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
Definition: ERF_NOAHMP.H:57
std::string Lsm_DataName(const int &varIdx) override
Definition: ERF_NOAHMP.H:154
int khi_lsm
Definition: ERF_NOAHMP.H:388
bool m_nsoil_resolved
Definition: ERF_NOAHMP.H:319
NOAHMP()
Definition: ERF_NOAHMP.H:67
std::string Lsm_FluxName(const int &varIdx) override
Definition: ERF_NOAHMP.H:177
amrex::Vector< amrex::BCRec > m_domain_bcs_type
Definition: ERF_NOAHMP.H:376
void Plot_Landfile(const int &nstep) override
Definition: ERF_NOAHMP_IO.cpp:46
virtual void Init(const int &, const amrex::MultiFab &, const amrex::Geometry &, const amrex::Geometry &, amrex::Vector< amrex::BCRec > &, amrex::IntVect &, const amrex::Real &, amrex::Vector< amrex::Vector< std::string >> &)
Definition: ERF_NullSurf.H:27
static std::string m_precip_snapshot_name(const std::string &dir, int l, int s)
Definition: ERF_NOAHMP.H:331
bool m_idealized_init
Definition: ERF_NOAHMP.H:445
amrex::Array< amrex::MultiFab *, LsmFlux_NOAHMP::NumVars > lsm_lev0_flux
Definition: ERF_NOAHMP.H:407
amrex::Array< FabPtr, LsmFlux_NOAHMP::NumVars > lsm_fab_flux
Definition: ERF_NOAHMP.H:401
bool m_updated
Definition: ERF_NOAHMP.H:433
int Get_LSM_Step() const override
Definition: ERF_NOAHMP.H:222
void Write_Lsm_Restart(const std::string &dir) const override
Definition: ERF_NOAHMP_IO.cpp:54
amrex::Vector< std::string > LsmDataName
Definition: ERF_NOAHMP.H:357
std::shared_ptr< amrex::MultiFab > FabPtr
Definition: ERF_NOAHMP.H:59
bool m_interp_pending
Definition: ERF_NOAHMP.H:438
amrex::Vector< int > LsmDataMap
Definition: ERF_NOAHMP.H:351
void read_results(const amrex::MFIter &mfi, const erf_noahmp::NoahmpBlockViews &blk, const amrex::Box &bx, const amrex::Box &gbx, amrex::MultiFab &cons_in)
Definition: ERF_NOAHMP_Advance.cpp:298
int Lsm_DataIndex(const std::string &varname) override
Definition: ERF_NOAHMP.H:163
amrex::Vector< std::unique_ptr< amrex::FArrayBox > > noahmp_output_tmp
Definition: ERF_NOAHMP.H:418
int soil_data_idx(int g, int k) const
Definition: ERF_NOAHMP.H:313
amrex::Vector< std::unique_ptr< amrex::FArrayBox > > noahmp_input_tmp
Definition: ERF_NOAHMP.H:417
void stage_forcing(const amrex::MFIter &mfi, const erf_noahmp::NoahmpBlockViews &blk, const amrex::Box &bx, const int &klo, const int &lev, const bool is_moist, amrex::MultiFab &cons_in, amrex::MultiFab &xvel_in, amrex::MultiFab &yvel_in, amrex::MultiFab *z_nd, const erf_noahmp::PrecipSlots &precip, amrex::Vector< erf_noahmp::ClampedPrecipCell > &clamped_cells, amrex::Vector< erf_noahmp::InvariantPrecipCell > &invariant_cells)
Definition: ERF_NOAHMP_Advance.cpp:144
bool m_radiation_feeds_lsm
Definition: ERF_NOAHMP.H:471
int m_nsoil
Definition: ERF_NOAHMP.H:411
int Lsm_Flux_Size() override
Definition: ERF_NOAHMP.H:150
bool Get_Update_Status() override
Definition: ERF_NOAHMP.H:217
int Lsm_Data_Size() override
Definition: ERF_NOAHMP.H:146
amrex::Geometry Lsm_Geom() override
Definition: ERF_NOAHMP.H:141
amrex::IntVect m_refRatio
Definition: ERF_NOAHMP.H:373
void Read_Lsm_Restart(const std::string &dir) override
Definition: ERF_NOAHMP_IO.cpp:73
amrex::Vector< FabPtr > lsm_fab_data
Definition: ERF_NOAHMP.H:398
NoahmpIO_vector noahmpio_vect
Definition: ERF_NOAHMP.H:414
int m_lsm_data_size
Definition: ERF_NOAHMP.H:345
erf_noahmp::PrecipSlots collect_precip_sources(const SurfacePrecipAccumulationSources &precip_sources)
Definition: ERF_NOAHMP_Precip.cpp:20
bool m_checked_radiation_inputs
Definition: ERF_NOAHMP.H:452
void with_land_comm(const std::function< void(NoahmpIO_type &)> &fn) const
Definition: ERF_NOAHMP_IO.cpp:19
int m_interp_nstep
Definition: ERF_NOAHMP.H:439
void report_precip_diagnostics(const int &lev, const amrex::Vector< erf_noahmp::ClampedPrecipCell > &clamped_cells, const amrex::Vector< erf_noahmp::InvariantPrecipCell > &invariant_cells)
Definition: ERF_NOAHMP_Precip.cpp:80
virtual ~NOAHMP()=default
int m_lev
Definition: ERF_NOAHMP.H:430
int m_first_advance_nstep
Definition: ERF_NOAHMP.H:465
amrex::Geometry m_lsm_geom
Definition: ERF_NOAHMP.H:369
int m_itimestep
Definition: ERF_NOAHMP.H:381
amrex::Geometry m_geom0
Definition: ERF_NOAHMP.H:366
void prepare_precip_snapshots(const int &lev, const erf_noahmp::PrecipSlots &precip)
Definition: ERF_NOAHMP_Precip.cpp:38
bool m_has_nc_file
Definition: ERF_NOAHMP.H:442
void Define(SolverChoice &sc) override
Definition: ERF_NOAHMP.H:74
int m_nz_lsm
Definition: ERF_NOAHMP.H:391
amrex::Vector< amrex::MultiFab * > lsm_lev0_data
Definition: ERF_NOAHMP.H:404
int m_lsm_flux_size
Definition: ERF_NOAHMP.H:348
amrex::Vector< amrex::Array< std::unique_ptr< amrex::MultiFab >, NoahmpPrecipSlot::NumSlots > > m_precip_accum_prev
Definition: ERF_NOAHMP.H:423
int Lsm_FluxIndex(const std::string &varname) override
Definition: ERF_NOAHMP.H:186
amrex::Real m_dtbl
Definition: ERF_NOAHMP.H:385
void interp_from_lev0(const int &lev, amrex::MultiFab &cons_in, const int &nstep)
Definition: ERF_NOAHMP_Advance.cpp:35
void Lsm_Set_Lev0_Flux_Ptr(const int &varIdx, amrex::MultiFab *lev0_flux_ptr) override
Definition: ERF_NOAHMP.H:208
amrex::Vector< int > LsmFluxMap
Definition: ERF_NOAHMP.H:354
void Advance_With_State(const int &lev, amrex::MultiFab &cons_in, amrex::MultiFab &xvel_in, amrex::MultiFab &yvel_in, amrex::MultiFab *hfx3_out, amrex::MultiFab *qfx3_out, const SurfacePrecipAccumulationSources &precip_sources, const amrex::Real &elapsed_time, const amrex::Real &dt, const int &nstep, const bool updated_lev0, amrex::MultiFab *z_nd) override
Definition: ERF_NOAHMP_Advance.cpp:433
std::string m_radiation_model_name
Definition: ERF_NOAHMP.H:472
void Lsm_Set_Lev0_Data_Ptr(const int &varIdx, amrex::MultiFab *lev0_data_ptr) override
Definition: ERF_NOAHMP.H:199
void Set_LSM_Step(int step) override
Definition: ERF_NOAHMP.H:228
amrex::MultiFab * Lsm_Data_Ptr(const int &varIdx) override
Definition: ERF_NOAHMP.H:123
bool m_warned_radiation_inputs
Definition: ERF_NOAHMP.H:456
static constexpr int m_num_soil_groups
Definition: ERF_NOAHMP.H:309
amrex::Array< std::unique_ptr< amrex::MultiFab >, NoahmpPrecipSlot::NumSlots > m_precip_accum_restored
Definition: ERF_NOAHMP.H:427
void m_ensure_nsoil_resolved()
Definition: ERF_NOAHMP.H:320
bool Runs_Own_Land_Driver() const override
Definition: ERF_NOAHMP.H:90
amrex::Vector< std::string > LsmFluxName
Definition: ERF_NOAHMP.H:360
void advance_precip_snapshots(const int &lev, const erf_noahmp::PrecipSlots &precip)
Definition: ERF_NOAHMP_Precip.cpp:66
amrex::Geometry m_geom
Definition: ERF_NOAHMP.H:363
bool time_to_fire(const amrex::Real &elapsed_time)
Definition: ERF_NOAHMP_Advance.cpp:128
amrex::Real m_dz_lsm
Definition: ERF_NOAHMP.H:394
amrex::MultiFab * Lsm_Flux_Ptr(const int &varIdx) override
Definition: ERF_NOAHMP.H:132
Definition: ERF_NullSurf.H:15
virtual void Init(const int &, const amrex::MultiFab &, const amrex::Geometry &, const amrex::Geometry &, amrex::Vector< amrex::BCRec > &, amrex::IntVect &, const amrex::Real &, amrex::Vector< amrex::Vector< std::string >> &)
Definition: ERF_NullSurf.H:27
@ NumVars
Definition: ERF_NOAHMP_Fields.H:116
@ NumVars
Definition: ERF_NOAHMP_Fields.H:129
@ NumSlots
Definition: ERF_NOAHMP_Fields.H:142
@ precip
Definition: ERF_SLM.H:135
Definition: ERF_NOAHMP.H:31
real(c_double), parameter g
Definition: ERF_module_model_constants.F90:19
Definition: ERF_DataStruct.H:743
static InitType init_type
Initial-condition source selected for the run.
Definition: ERF_DataStruct.H:2983
bool rad_feeds_lsm() const
True when the radiation model's outputs feed the land model (downwelling shortwave,...
Definition: ERF_DataStruct.H:3483
RadiationType rad_type
Radiation model.
Definition: ERF_DataStruct.H:3465
Definition: ERF_SurfacePrecipitation.H:40
Definition: ERF_NOAHMP.H:42
int i
Definition: ERF_NOAHMP.H:42
amrex::Real raw_mm
Definition: ERF_NOAHMP.H:42
int j
Definition: ERF_NOAHMP.H:42
Definition: ERF_NOAHMP.H:46
int j
Definition: ERF_NOAHMP.H:46
amrex::Real froz_mm
Definition: ERF_NOAHMP.H:46
amrex::Real total_mm
Definition: ERF_NOAHMP.H:46
int i
Definition: ERF_NOAHMP.H:46
Definition: ERF_NOAHMP.H:50
NoahmpIO_type * io
Definition: ERF_NOAHMP.H:51
amrex::Array4< amrex::Real > output
Definition: ERF_NOAHMP.H:53
amrex::Array4< amrex::Real > input
Definition: ERF_NOAHMP.H:52
Definition: ERF_NOAHMP.H:34
bool have_any
Definition: ERF_NOAHMP.H:38
bool has[NoahmpPrecipSlot::NumSlots]
Definition: ERF_NOAHMP.H:37
const amrex::MultiFab * accum[NoahmpPrecipSlot::NumSlots]
Definition: ERF_NOAHMP.H:35
amrex::Real factor[NoahmpPrecipSlot::NumSlots]
Definition: ERF_NOAHMP.H:36