REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA.H
Go to the documentation of this file.
1#ifndef REMORA_H_
2#define REMORA_H_
3
4#include <string>
5#include <limits>
6#include <array>
7#include <memory>
8
9#ifdef _OPENMP
10#include <omp.h>
11#endif
12
13#include <AMReX_AmrCore.H>
14#include <AMReX_BCRec.H>
15#include <AMReX_InterpFaceRegister.H>
16
17#include <AMReX_ParallelDescriptor.H>
18#include <AMReX_ParmParse.H>
19#include <AMReX_MultiFabUtil.H>
20#include <AMReX_FillPatchUtil.H>
21#include <AMReX_VisMF.H>
22#include <AMReX_PhysBCFunct.H>
23#include <AMReX_YAFluxRegister.H>
24#include <AMReX_ErrorList.H>
25
26#ifdef AMREX_MEM_PROFILING
27#include <AMReX_MemProfiler.H>
28#endif
29
30#include <REMORA_PhysBCFunct.H>
31#include <REMORA_FillPatcher.H>
32
33#include <REMORA_IndexDefines.H>
35#include <REMORA_DataStruct.H>
36#include <REMORA_Derive.H>
37#include <REMORA_ErrorTag.H>
38#include <REMORA_Biology.H>
39#include "REMORA_ProbCoords.H"
40#include "REMORA_prob_common.H"
41
42#ifdef REMORA_USE_PARTICLES
43#include "REMORA_ParticleData.H"
44#endif
45
46#ifdef REMORA_USE_NETCDF
47#include "REMORA_NCInterface.H"
48#include "REMORA_NCTimeSeries.H"
51#endif
52
53#ifdef REMORA_USE_MOAB
54#include "REMORA_MOAB.H"
55#endif
56
57#include <iostream>
59#ifdef AMREX_LAZY
60#include <AMReX_Lazy.H>
61#endif
62
63#ifndef AMREX_USE_MPI
64using amrex::MPI_COMM_WORLD;
65using amrex::MPI_Comm;
66#endif
67
79
80// Forward declarations to resolve circular dependency
81class ProblemBase;
82#ifdef REMORA_USE_NETCDF
83class NCTimeSeries;
86#endif
87
88/*!
89 * \brief Class that stores all relevant simulation state data with methods for time stepping
90 */
91class REMORA
92 : public amrex::AmrCore
93{
94public:
95 enum class DriverAtmosForcingMode : int {
96 State = 0,
97 Flux
98 };
99
100 static constexpr bool DriverUsesStateForcing (DriverAtmosForcingMode mode) noexcept
101 {
103 }
104
105 REMORA ();
106 REMORA (const amrex::RealBox& rb, int max_level_in, const amrex::Vector<int>& n_cell_in, int coord, const amrex::Vector<amrex::IntVect>& ref_ratio, const amrex::Array<int,AMREX_SPACEDIM>& is_per, std::string prefix);
107 virtual ~REMORA ();
108
109 /** \brief Advance solution to final time */
110 void Evolve ();
111
112 /** \brief Write checkpoint and plotfiles at end of simulation */
113 void WriteAtFinalTime ();
114
115 /** \brief Write checkpoint and plotfiles at intermediate point of simulation, if needed */
116 void WriteAtIntermediateTime (int step, amrex::Real cur_time);
117
118 /** \brief Tag cells for refinement */
119 virtual void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow) override;
120
121 /** \brief Initialize multilevel data */
122 void InitData ();
123 amrex::Real EvolveOneStep (amrex::Real time, amrex::Real dt_request);
124 /** \brief Set remora.start_time. Call before InitData, which starts the clock from it. */
125 void SetStartTime (double time) noexcept { start_time = time; }
126
131
132 // Consume the driver-supplied DOWNWARD longwave on vec_longwave_down instead
133 // of computing longwave internally. Set programmatically rather than through
134 // ParmParse so a coupled run's job_info still reflects the deck rather than
135 // driver-injected keys. Safe any time before the first step: the lane is
136 // allocated whenever bulk fluxes are on, independent of lwrad_type.
137 void SetLongwaveFromDriver ();
138
139 // Per state lane, whether the deck named its forcing - either the selector
140 // (remora.<x>_type, its legacy aliases, remora.wind_type) or the constant
141 // (remora.air_humidity and friends). A coupling driver uses it to leave such
142 // a lane with the deck instead of overriding it with atmospheric data.
143 //
144 // Not answerable from ParmParse afterwards: queryAdd materializes the
145 // defaults. See SolverChoice::bulk_flux_type_specified.
147 std::array<bool, AtmosState::NumTypes>& deck_configured) const;
148
149 // Driver currently consumes BoxArray/DistributionMapping only. If we later
150 // need exact copy semantics, promote these to expose IndexType/ngrow
151 // explicitly or return the underlying MultiFab pointer/reference instead.
152 void GetAtmosToOceanRhoLayout (amrex::BoxArray& ba,
153 amrex::DistributionMapping& dm) const;
154 void GetAtmosToOceanUFaceLayout (amrex::BoxArray& ba,
155 amrex::DistributionMapping& dm) const;
156 void GetAtmosToOceanVFaceLayout (amrex::BoxArray& ba,
157 amrex::DistributionMapping& dm) const;
158 // Returns pointers to level-0 psi-point coordinate MultiFabs (vec_xp/vec_yp)
159 // used to build atmos->ocean remap weights. Sets both to nullptr if
160 // unavailable in the current configuration rather than aborting.
161 void GetAtmosToOceanPsiCoordinates (const amrex::MultiFab*& x_psi,
162 const amrex::MultiFab*& y_psi) const;
163
164 // Returns pointers to level-0 psi-point spherical coordinate MultiFabs
165 // (vec_lonp/vec_latp, degrees east/north). These are the corner arrays a
166 // coupled driver needs when the two solvers do not share a projected
167 // Cartesian frame: SCRIP/COAWST likewise remaps in lon/lat and reads
168 // lon_psi/lat_psi for spherical ROMS grids (see COAWST
169 // Lib/SCRIP_COAWST/read_roms.f). Sets both to nullptr when the grid file
170 // carried no spherical coordinates rather than aborting.
171 void GetAtmosToOceanPsiLonLat (const amrex::MultiFab*& lon_psi,
172 const amrex::MultiFab*& lat_psi) const;
173
174 // Returns the level-0 wet/dry masks (1 = wet, 0 = land) at rho, u-face,
175 // and v-face points, used by the driver to exclude land cells from
176 // remap destination stencils. Sets pointers to nullptr if unavailable.
177 void GetLandSeaMasks (const amrex::MultiFab*& mskr,
178 const amrex::MultiFab*& msku,
179 const amrex::MultiFab*& mskv) const;
180
181 /** \brief Init (NOT restart or regrid) */
182 void init_only (int lev, amrex::Real time);
183
184 /** \briefRestart */
185 void restart ();
186
187 /** \brief Called after every level 0 timestep */
188 void post_timestep (int nstep, amrex::Real time, amrex::Real dt_lev);
189
190 /**
191 * \brief Extracts SST from the 3D conservative state for the atmospheric driver.
192 *
193 * Reads Temp_comp at the top water-column cell (k_sfc), converts from
194 * Celsius to Kelvin, and copies the result into state[SSTIndex].
195 *
196 * @param[in,out] state OCN2ATM slab buffer sized by the driver (one MultiFab
197 * per ocean-to-atmosphere export layer). state[SSTIndex]
198 * (index 0) is overwritten with sea-surface temperature
199 * (SST) sampled from the Temp_comp tracer at the uppermost
200 * sigma level (k = Nz) and converted from degrees Celsius
201 * to Kelvin for the atmospheric driver. An empty vector or
202 * null state[0] is treated as a no-op.
203 * @param[in ] time Current ocean model time (unused; retained for driver
204 * interface conformance).
205 */
206 // dst_land_mask is the ERF land mask (1 = land, 0 = water) on the
207 // destination (ERF) layout; destination cells over land are zeroed.
208 // Pass nullptr to skip masking.
209 void PackSurfaceState (amrex::Vector<amrex::MultiFab*>& state, amrex::Real time,
210 const amrex::MultiFab* weight_o2a_mf,
211 const amrex::iMultiFab* index_o2a_mf,
213 const amrex::iMultiFab* dst_land_mask = nullptr);
214
215 /**
216 * \brief Receives atmospheric states from the driver and applies unit conversions.
217 *
218 * Fills REMORA's internal forcing MultiFabs from states and records which
219 * lanes were successfully updated in driver_atmos_state_from_driver.
220 * Unit conversions applied: Pair Pa to mb; Tair K to Celsius.
221 *
222 * @param[in] states ATM2OCN forcing slab buffer from the driver (Warner et al.
223 * 2010, Block B state-passing contract), indexed by AtmosState.
224 * Expected units per lane:
225 * Uwind/Vwind: 10-m winds [m/s];
226 * Pair: mean sea-level pressure [Pa, converted to mb];
227 * Qair: near-surface specific humidity [kg/kg];
228 * Tair: 2-m air temperature [K, converted to degC];
229 * Cloud: cloud fraction [0-1];
230 * Rain: precipitation rate [kg/m^2/s];
231 * SWrad/LWrad: downwelling shortwave/longwave radiation [W/m^2].
232 * Missing lanes (null pointer or index out of range) are skipped;
233 * driver_atmos_state_from_driver tracks populated lanes for the
234 * bulk-flux parameterization fallback logic.
235 * @param[in] time Current ocean model time (unused; retained for driver
236 * interface conformance).
237 */
238 void ApplyAtmosphericStates (const amrex::Vector<amrex::MultiFab*>& states, amrex::Real time);
239
240 /**
241 * \brief Receives atmospheric flux lanes from the driver and assembles REMORA flux inputs.
242 *
243 * Expected active-lane order matches the driver FluxPassing contract:
244 * tau_x, tau_y, SHflux, LHflux, SWrad, LWrad, rain, evap.
245 *
246 * This routine copies imported forcing lanes into REMORA's existing flux arrays
247 * and assembles vec_stflux directly from those imported values. It intentionally
248 * leaves the downstream salt_old multiplication to setup_step().
249 */
250 void ApplyAtmosphericFluxes (const amrex::Vector<amrex::MultiFab*>& states, amrex::Real time);
251 //! Latch so the flux validation block prints once per run unless remora.v >= 1
253 //! Worst wet surface temperature extremes (K) and NaN count already warned about;
254 //! the warning repeats only when a later exchange is worse. Start at the bounds.
255 amrex::Real m_warned_surface_temp_min = amrex::Real(273.15 - 2.5);
256 amrex::Real m_warned_surface_temp_max = amrex::Real(273.15 + 40.0);
258
259 // Diagnostics
260
261 /** \brief Integrate conserved quantities for diagnostics */
262 void sum_integrated_quantities (amrex::Real time);
263
264 /** \brief Perform the volume-weighted sum */
265 amrex::Real
266 volWgtSumMF (int lev,
267 const amrex::MultiFab& mf, int comp, bool local, bool finemask);
268
269 /** \brief Decide if it is time to take an action */
270 bool is_it_time_for_action (int nstep, amrex::Real time, amrex::Real dt,
271 int action_interval, amrex::Real action_per);
272
273 /** \brief Make a new level using provided BoxArray and DistributionMapping and
274 * fill with interpolated coarse level data.
275 * Overrides the pure virtual function in AmrCore
276 */
277 virtual void MakeNewLevelFromCoarse (int lev, amrex::Real time, const amrex::BoxArray& ba,
278 const amrex::DistributionMapping& dm) override;
279
280 /** \brief Remake an existing level using provided BoxArray and DistributionMapping and
281 * fill with existing fine and coarse data.
282 * Overrides the pure virtual function in AmrCore
283 */
284 virtual void RemakeLevel (int lev, amrex::Real time, const amrex::BoxArray& ba,
285 const amrex::DistributionMapping& dm) override;
286
287 /** \brief Delete level data
288 * Overrides the pure virtual function in AmrCore
289 */
290 virtual void ClearLevel (int lev) override;
291
292 /** \brief Make a new level from scratch using provided BoxArray and DistributionMapping.
293 * Only used during initialization.
294 * Overrides the pure virtual function in AmrCore
295 */
296 virtual void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba,
297 const amrex::DistributionMapping& dm) override;
298
299 /** \brief Set pm and pn arrays and x/y coords on level lev */
300 void set_grid_scale (int lev);
301
302 /** \brief Set x/y coords on level lev based on pm and pn */
304
305 /** \brief Set curvilinear derivative terms on level lev based on pm and pn */
307
308 /** \brief Set pm/pn by averaging down from higher-resolution grid */
310
311 /** \brief Set zeta components to be equal to time-averaged Zt_avg1 */
312 void set_zeta_to_Ztavg (int lev, bool apply_eminusp=true);
313
314 /** \brief Calculate u-, v-, and psi-point masks based on rho-point masks after analytic initialization */
315 void calculate_nodal_masks (int lev);
316
317 /** \brief Copy maskr to all z levels */
318 void fill_3d_masks (int lev);
319
320 /** \brief compute dt from CFL considerations */
321 amrex::Real estTimeStep (int lev) const;
322
323 /** \brief Interface for advancing the data at one level by one "slow" timestep */
325 amrex::MultiFab& cons_old, amrex::MultiFab& cons_new,
326 amrex::MultiFab& xvel_old, amrex::MultiFab& yvel_old, amrex::MultiFab& zvel_old,
327 amrex::MultiFab& xvel_new, amrex::MultiFab& yvel_new, amrex::MultiFab& zvel_new,
328 amrex::MultiFab& source,
329 const amrex::Geometry fine_geom,
330 const amrex::Real dt, const amrex::Real time);
331
332 /** \brief Make mask to zero out covered cells (for mesh refinement) */
333 amrex::MultiFab& build_fine_mask(int lev);
334
335 /** \brief main driver for writing AMReX plotfiles */
336 void WritePlotFile (int istep);
337
338 /** \brief write out particular data to an AMReX plotfile */
340 int nlevels,
341 const amrex::Vector<const amrex::MultiFab*> &mf,
342 const amrex::Vector<const amrex::MultiFab*> &mf_nd,
343 const amrex::Vector<const amrex::MultiFab*> &mf_u,
344 const amrex::Vector<const amrex::MultiFab*> &mf_v,
345 const amrex::Vector<const amrex::MultiFab*> &mf_w,
346 const amrex::Vector<const amrex::MultiFab*> &mf_2d_rho,
347 const amrex::Vector<const amrex::MultiFab*> &mf_2d_u,
348 const amrex::Vector<const amrex::MultiFab*> &mf_2d_v,
349 const amrex::Vector<std::string> &varnames_3d,
350 const amrex::Vector<std::string> &varnames_2d_rho,
351 const amrex::Vector<std::string> &varnames_2d_u,
352 const amrex::Vector<std::string> &varnames_2d_v,
353 const amrex::Vector<amrex::Geometry>& my_geom,
354 double time,
355 const amrex::Vector<int> &level_steps,
356 const amrex::Vector<amrex::IntVect>& rr,
357 const std::string &versionName = "HyperCLaw-V1.1",
358 const std::string &levelPrefix = "Level_",
359 const std::string &mfPrefix = "Cell",
360 const amrex::Vector<std::string>& extra_dirs = amrex::Vector<std::string>()) const;
361
362
363
364 /** \brief write out header data for an AMReX plotfile */
366 int nlevels,
367 const amrex::Vector<amrex::BoxArray> &bArray,
368 const amrex::Vector<std::string> &varnames_3d,
369 const amrex::Vector<std::string> &varnames_2d_rho,
370 const amrex::Vector<std::string> &varnames_2d_u,
371 const amrex::Vector<std::string> &varnames_2d_v,
372 const amrex::Vector<amrex::Geometry>& my_geom,
373 double time,
374 const amrex::Vector<int> &level_steps,
375 const amrex::Vector<amrex::IntVect>& rr,
376 const std::string &versionName,
377 const std::string &levelPrefix,
378 const std::string &mfPrefix) const;
379
380 /** \brief default prefix for input file parameters */
381 std::string pp_prefix {"remora"};
382
383 /** \brief multilevel data container for last step's scalar data: temperature, salinity, passive tracer */
384 amrex::Vector<amrex::MultiFab*> cons_old;
385 /** \brief multilevel data container for last step's x velocities (u in ROMS) */
386 amrex::Vector<amrex::MultiFab*> xvel_old;
387 /** \brief multilevel data container for last step's y velocities (v in ROMS) */
388 amrex::Vector<amrex::MultiFab*> yvel_old;
389 /** \brief multilevel data container for last step's z velocities (largely unused; W stored separately) */
390 amrex::Vector<amrex::MultiFab*> zvel_old;
391
392 /** \brief multilevel data container for current step's scalar data: temperature, salinity, passive tracer */
393 amrex::Vector<amrex::MultiFab*> cons_new;
394 /** \brief multilevel data container for current step's x velocities (u in ROMS) */
395 amrex::Vector<amrex::MultiFab*> xvel_new;
396 /** \brief multilevel data container for current step's y velocities (v in ROMS) */
397 amrex::Vector<amrex::MultiFab*> yvel_new;
398 /** \brief multilevel data container for current step's z velocities (largely unused; W stored separately) */
399 amrex::Vector<amrex::MultiFab*> zvel_new;
400
401 /** \brief multilevel data container for high res initial data: temperature, salinity, passive tracer */
402 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_cons_full_domain;
403 /** \brief multilevel data container for high res initial x velocities (u in ROMS) */
404 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_xvel_full_domain;
405 /** \brief multilevel data container for high res initial y velocities (v in ROMS) */
406 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_yvel_full_domain;
407 /** \brief multilevel data container for current step's z velocities (largely unused; W stored separately) */
408
409 // Program state data is represented by vectors of pointers to AMReX Multifabs.
410 // There is one pointer per level
411
412 /** \brief Bathymetry data (2D, positive valued, h in ROMS) **/
413 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_h;
414
415 /** \brief Bathymetry data on the whole domain at each potential level **/
416 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_h_full_domain;
417
418 /** \brief Land/sea mask at cell centers on the whole domain at each potential level.
419 * Specified at hires_grid_level and coarsened down from there, so that a refined
420 * coastline and the bathymetry it goes with come from the same grid. **/
421 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_mskr_full_domain;
422
423 /** \brief Width of cells in the vertical (z-) direction (3D, Hz in ROMS) */
424 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Hz;
425 /** \brief u-volume flux (3D) */
426 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Huon;
427 /** \brief v-volume flux (3D) */
428 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Hvom;
429 /** \brief u velocity RHS (3D, includes horizontal and vertical advection) */
430 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_ru;
431 /** \brief v velocity RHS (3D, includes horizontal and vertical advection) */
432 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rv;
433 /** \brief u velocity RHS (2D, includes horizontal and vertical advection) */
434 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_ru2d;
435 /** \brief v velocity RHS (2D, includes horizontal and vertical advection) */
436 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rv2d;
437 /** \brief u velocity RHS, integrated, including advection and bottom/surface stresses (2D) */
438 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rufrc;
439 /** \brief v velocity RHS, integrated, including advection and bottom/surface stresses (2D) */
440 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rvfrc;
441 /** \brief Vertical viscosity coefficient (3D) */
442 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Akv;
443 /** \brief Vertical diffusion coefficient (3D) */
444 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Akt;
445 /** \brief Harmonic viscosity defined on the psi points (corners of horizontal grid cells) */
446 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_visc2_p;
447 /** \brief Harmonic viscosity defined on the rho points (centers) */
448 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_visc2_r;
449 /** \brief Harmonic diffusivity for temperature / salinity */
450 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_diff2;
451
452 /** \brief z coordinates at rho points (cell centers) */
453 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_z_r;
454
455 /** \brief z coordinates at w points (faces between z-cells) */
456 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_z_w;
457 /** \brief Scaled vertical coordinate (range [0,1]) that transforms to z, defined at rho points (cell centers) */
458 amrex::Gpu::DeviceVector<amrex::Real> s_r;
459 /** \brief Scaled vertical coordinate (range [0,1]) that transforms to z, defined at w-points (cell faces) */
460 amrex::Gpu::DeviceVector<amrex::Real> s_w;
461
462 //amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_s_r;
463 //amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_s_w;
464 //amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Cs_r;
465 //amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Cs_w;
466
467 /** \brief Stretching coefficients at rho points */
468 amrex::Gpu::DeviceVector<amrex::Real> Cs_r;
469 /** \brief Stretching coefficients at w points */
470 amrex::Gpu::DeviceVector<amrex::Real> Cs_w;
471
472 /** \brief z coordinates at psi points (cell nodes) **/
473 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_z_phys_nd;
474
475 /** \brief Average of the free surface, zeta (2D) */
476 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Zt_avg1;
477
478 /** \brief Surface stress in the u direction */
479 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_sustr;
480 /** \brief Surface stress in the v direction */
481 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_svstr;
482
483 /** \brief Wind in the u direction, defined at rho-points */
484 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_uwind;
485 /** \brief Wind in the v direction, defined at rho-points */
486 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_vwind;
487 /** \brief Air temperature [°C], defined at rho-points */
488 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Tair;
489 /** \brief Specific humidity [kg/kg], defined at rho-points */
490 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_qair;
491 /** \brief Air pressure [mb], defined at rho-points */
492 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Pair;
493
494 /** \brief Shortwave radiation flux [W/m²], defined at rho-points */
495 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_srflx;
496 /** \brief longwave radiation */
497 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_lrflx;
498 /** \brief Downward longwave radiation */
499 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_longwave_down;
500 /** \brief latent heat flux */
501 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_lhflx;
502 /** \brief sensible heat flux */
503 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_shflx;
504
505 /** \brief Surface tracer flux; working arrays */
506 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_stflx;
507 /** \brief Surface tracer flux; input arrays */
508 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_stflux;
509 /** \brief Bottom tracer flux; working arrays */
510 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_btflx;
511 /** \brief Bottom tracer flux; input arrays */
512 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_btflux;
513
514 /** \brief precipitation rate [kg/m^2/s] */
515 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rain;
516 /** \brief evaporation rate [kg/m^2/s] */
517 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_evap;
518 /** \brief cloud cover fraction [0-1], defined at rho-points */
519 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_cloud;
520 /** \brief evaporation minus precipitation [kg/m^2/s], defined at rho-points */
521 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_EminusP;
522
523 /** \brief provenance flags for driver-supplied atmospheric forcing lanes */
524 std::array<bool, AtmosState::NumTypes> driver_atmos_state_from_driver {};
525 /** \brief True once REMORA has received forcing through the coupling driver. */
527 /** \brief Driver-level direction flag copied in before InitData. */
529 /** \brief Active atmosphere-to-ocean forcing contract on the most recent driver apply. */
531
532 /** \brief Linear drag coefficient [m/s], defined at rho points */
533 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rdrag;
534 /** \brief Quadratic drag coefficient [unitless], defined at rho points */
535 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rdrag2;
536 /** \brief Bottom roughness length [m], defined at rho points */
537 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_ZoBot;
538
539 /** \brief Bottom stress in the u direction */
540 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_bustr;
541 /** \brief Bottom stress in the v direction */
542 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_bvstr;
543
544 /** \brief time average of barotropic x velocity flux (2D) */
545 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_DU_avg1;
546 /** \brief correct time average of barotropic x velocity flux for coupling (2D) */
547 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_DU_avg2;
548 /** \brief time average of barotropic y velocity flux */
549 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_DV_avg1;
550 /** \brief correct time average of barotropic y velocity flux for coupling (2D) */
551 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_DV_avg2;
552 /** \brief DU_avg2 per unit cell edge length, at the start and end of this level's step.
553 * What a subcycled finer level interpolates to get a mass-conserving ubar (2D) */
554 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Dubar_old;
555 /** \brief see vec_Dubar_old (2D) */
556 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Dubar_new;
557 /** \brief DV_avg2 per unit cell edge length, see vec_Dubar_old (2D) */
558 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Dvbar_old;
559 /** \brief see vec_Dvbar_old (2D) */
560 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Dvbar_new;
561 /** \brief free surface at the start and end of this level's step, every leapfrog
562 * component holding the same value. What a subcycled finer level interpolates
563 * in time to get its contact points, as ROMS's put_refine2d does (2D) */
564 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_zeta_crse_old;
565 /** \brief see vec_zeta_crse_old (2D) */
566 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_zeta_crse_new;
567 /** \brief barotropic x velocity for the RHS (2D) */
568 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rubar;
569 /** \brief barotropic y velocity for the RHS (2D) */
570 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rvbar;
571 /** \brief free surface height for the RHS (2D) */
572 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rzeta;
573 /** \brief barotropic x velocity (2D) */
574 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_ubar;
575 /** \brief barotropic y velocity (2D) */
576 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_vbar;
577 /** \brief free surface height (2D) */
578 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_zeta;
579
580 /** \brief high resolution initial free surface height (2D) */
581 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_zeta_full_domain;
582
583 /** \brief land/sea mask at cell centers (2D) */
584 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_mskr;
585 /** \brief land/sea mask at x-faces (2D) */
586 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_msku;
587 /** \brief land/sea mask at y-faces (2D) */
588 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_mskv;
589 /** \brief land/sea mask at cell corners (2D) */
590 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_mskp;
591 /** \brief land/sea mask at cell centers, copied to all z levels (3D) */
592 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_mskr3d;
593
594 /** \brief the level's rho-, u- and v-masks copied onto the layout of the level above it
595 * coarsened, which is the layout the two-way average-down computes on. Indexed by the
596 * coarse level of the pair. Built on demand and reused until a regrid, since the masks
597 * are a function of position alone and so do not change between them. **/
598 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_mskr_crse_on_fine;
599 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_msku_crse_on_fine;
600 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_mskv_crse_on_fine;
601
602 /** \brief horizontal scaling factor: 1 / dx (2D) */
603 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_pm;
604 /** \brief horizontal scaling factor: 1 / dy (2D) */
605 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_pn;
606 /** \brief horizontal scaling factor: 1 / dx (2D) on whole domain */
607 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_pm_full_domain;
608 /** \brief horizontal scaling factor: 1 / dy (2D) on whole domain */
609 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_pn_full_domain;
610
611 /** \brief coriolis factor (2D) */
612 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_fcor;
613
614 /** \brief x_grid on rho points (2D) */
615 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_xr;
616 /** \brief y_grid on rho points (2D) */
617 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_yr;
618
619 /** \brief x_grid on u-points (2D) */
620 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_xu;
621 /** \brief y_grid on u-points (2D) */
622 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_yu;
623
624 /** \brief x_grid on v-points (2D) */
625 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_xv;
626 /** \brief y_grid on v-points (2D) */
627 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_yv;
628
629 /** \brief x_grid on psi-points (2D) */
630 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_xp;
631 /** \brief y_grid on psi-points (2D) */
632 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_yp;
633
634 /** \brief longitude on psi-points (2D, degrees east); only filled when the
635 * grid NetCDF file carries lon_psi */
636 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_lonp;
637 /** \brief latitude on psi-points (2D, degrees north); only filled when the
638 * grid NetCDF file carries lat_psi */
639 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_latp;
640
641 /** \brief d(1/n)/d(xi) */
642 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_dndx;
643 /** \brief d(1/m)/d(eta) */
644 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_dmde;
645
646 /** \brief additional scratch space for calculations on temp, salt, etc */
647 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_sstore;
648
649 /** \brief density perturbation */
650 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rhoS;
651 /** \brief vertically-averaged density */
652 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_rhoA;
653 /** \brief Brunt-Vaisala frequency (3D) */
654 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_bvf;
655 /** \brief Thermal expansion coefficient (3D) */
656 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_alpha;
657 /** \brief Saline contraction coefficient (3D) */
658 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_beta;
659
660 /** \brief Weights for calculating avg1 in 2D advance */
661 amrex::Vector<amrex::Real> vec_weight1;
662 /** \brief Weights for calculating avg2 in 2D advance */
663 amrex::Vector<amrex::Real> vec_weight2;
664
665 // GLS
666 /** \brief Turbulent kinetic energy */
667 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_tke;
668 /** \brief Turbulent generic length scale */
669 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_gls;
670 /** \brief Vertical mixing turbulent length scale */
671 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Lscale;
672 /** \brief Turbulent kinetic energy vertical diffusion coefficient */
673 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Akk;
674 /** \brief Turbulent length scale vertical diffusion coefficient */
675 amrex::Vector<std::unique_ptr<amrex::MultiFab>> vec_Akp;
676
677 /** \brief Climatology nudging coefficients */
678 amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> vec_nudg_coeff;
679
680 /** \brief advance a single level for a single time step */
681 void Advance (int lev, amrex::Real time, amrex::Real dt_lev, int iteration, int ncycle);
682
683 /** \brief register this level's completed step as the coarse bracket the next finer
684 * level interpolates within */
685 void register_coarse_data (int lev, amrex::Real time, amrex::Real dt_lev);
686
687 /** \brief roll a two-snapshot history of a level's end-of-step 2D state */
688 void roll_2d_snapshot (amrex::Vector<std::unique_ptr<amrex::MultiFab>>& old_v,
689 amrex::Vector<std::unique_ptr<amrex::MultiFab>>& new_v,
690 int lev, const amrex::MultiFab& src, const amrex::MultiFab& like);
691
692 /** \brief set this level's barotropic contact points from its parent, mass-conservingly */
693 void set_2d_cf_bcs (int lev, amrex::Real time, int know, int knew);
694
695 /** \brief impose the parent's barotropic mass flux on the coarse-fine interface faces */
696 void set_2d_cf_flux (int lev, amrex::Real time,
697 amrex::MultiFab& mf_DUon, amrex::MultiFab& mf_DVom);
698
699 /** \brief store this level's barotropic mass flux per unit cell edge length */
700 void store_2d_flux (int lev);
701
702 /** \brief apply the lev/lev+1 tracer flux correction onto lev */
703 void reflux_to (int lev);
704
705 /** \brief check that fine cell edges sum to the coarse edge across an interface */
706 void check_cf_metrics (int crse_lev);
707
708 /** \brief Set everything up for a step on a level */
709 void setup_step(int lev, amrex::Real time, amrex::Real dt_lev);
710
711 /** \brief 3D advance on a single level */
712 void advance_3d_ml (int lev, amrex::Real dt_lev);
713
714 /** \brief 2D advance, one predictor/corrector step */
715 void advance_2d_onestep (int lev, amrex::Real dt_lev, amrex::Real dtfast_lev, int my_iif, int nfast_counter);
716
717 /** \brief Perform a 2D predictor (predictor_2d_step=True) or corrector (predictor_2d_step=False) step */
718 void advance_2d (int lev,
719 amrex::MultiFab const* mf_rhoS,
720 amrex::MultiFab const* mf_rhoA,
721 amrex::MultiFab * mf_ru2d,
722 amrex::MultiFab * mf_rv2d,
723 amrex::MultiFab * mf_rufrc,
724 amrex::MultiFab * mf_rvfrc,
725 amrex::MultiFab * mf_Zt_avg1,
726 std::unique_ptr<amrex::MultiFab>& mf_DU_avg1,
727 std::unique_ptr<amrex::MultiFab>& mf_DU_avg2,
728 std::unique_ptr<amrex::MultiFab>& mf_DV_avg1,
729 std::unique_ptr<amrex::MultiFab>& mf_DV_avg2,
730 std::unique_ptr<amrex::MultiFab>& mf_rubar,
731 std::unique_ptr<amrex::MultiFab>& mf_rvbar,
732 std::unique_ptr<amrex::MultiFab>& mf_rzeta,
733 std::unique_ptr<amrex::MultiFab>& mf_ubar,
734 std::unique_ptr<amrex::MultiFab>& mf_vbar,
735 amrex::MultiFab * mf_zeta,
736 amrex::MultiFab const* mf_h,
737 amrex::MultiFab const* mf_pm,
738 amrex::MultiFab const* mf_pn,
739 amrex::MultiFab const* mf_fcor,
740 amrex::MultiFab const* mf_visc2_p,
741 amrex::MultiFab const* mf_visc2_r,
742 amrex::MultiFab const* mf_mskr,
743 amrex::MultiFab const* mf_msku,
744 amrex::MultiFab const* mf_mskv,
745 amrex::MultiFab const* mf_mskp,
746 amrex::Real dtfast_lev,
748 bool first_2d_step, int my_iif,
749 int & next_indx1);
750
751 /** \brief Advance the 3D variables */
752 void advance_3d (int lev,
753 amrex::MultiFab& mf_cons,
754 amrex::MultiFab& mf_u , amrex::MultiFab& mf_v,
755 amrex::MultiFab* mf_sstore,
756 amrex::MultiFab* mf_ru , amrex::MultiFab* mf_rv,
757 std::unique_ptr<amrex::MultiFab>& mf_DU_avg1,
758 std::unique_ptr<amrex::MultiFab>& mf_DU_avg2,
759 std::unique_ptr<amrex::MultiFab>& mf_DV_avg1,
760 std::unique_ptr<amrex::MultiFab>& mf_DV_avg2,
761 std::unique_ptr<amrex::MultiFab>& mf_ubar,
762 std::unique_ptr<amrex::MultiFab>& mf_vbar,
763 std::unique_ptr<amrex::MultiFab>& mf_Akv,
764 std::unique_ptr<amrex::MultiFab>& mf_Akt,
765 std::unique_ptr<amrex::MultiFab>& mf_Hz,
766 std::unique_ptr<amrex::MultiFab>& mf_Huon,
767 std::unique_ptr<amrex::MultiFab>& mf_Hvom,
768 std::unique_ptr<amrex::MultiFab>& mf_z_w,
769 amrex::MultiFab const* mf_h,
770 amrex::MultiFab const* mf_pm,
771 amrex::MultiFab const* mf_pn,
772 amrex::MultiFab const* mf_mskr,
773 amrex::MultiFab const* mf_msku,
774 amrex::MultiFab const* mf_mskv,
775 const int N,
776 const amrex::Real dt_lev);
777
778 /** \brief Apply biological tracer source/sink terms */
779 void advance_biology (int lev, amrex::MultiFab const& mf_cons_old,
780 amrex::MultiFab& mf_cons_new,
781 int N, amrex::Real dt_lev);
782
783#ifdef REMORA_USE_FENNEL_FORT
784 /** \brief Path A oracle: apply biological source/sink terms through the
785 * ROMS Fennel Fortran kernel. Selected at run time by
786 * remora.use_biology_cpp_answer = 0. */
787 void advance_biology_fortran (int lev, amrex::MultiFab const& mf_cons_old,
788 amrex::MultiFab& mf_cons_new,
789 int N, amrex::Real dt_lev);
790#endif
791
792 /** \brief Calculate bulk temperature, salinity, wind fluxes */
793 void bulk_fluxes (int lev,
794 amrex::MultiFab* mf_cons,
795 amrex::MultiFab* mf_uwind,
796 amrex::MultiFab* mf_vwind,
797 amrex::MultiFab* mf_Tair,
798 amrex::MultiFab* mf_qair,
799 amrex::MultiFab* mf_Pair,
800 amrex::MultiFab* mf_srflx,
801 amrex::MultiFab* mf_longwave_down,
802 amrex::MultiFab* mf_evap,
803 amrex::MultiFab* mf_sustr,
804 amrex::MultiFab* mf_svstr,
805 amrex::MultiFab* mf_stflux,
806 amrex::MultiFab* mf_lrflx,
807 amrex::MultiFab* mf_lhflx,
808 amrex::MultiFab* mf_shflx,
809 const int N);
810
811 /** \brief Wrapper function for prestep */
812 void prestep (int lev,
813 amrex::MultiFab& mf_uold, amrex::MultiFab& mf_vold,
814 amrex::MultiFab& mf_u, amrex::MultiFab& mf_v,
815 amrex::MultiFab* mf_ru,
816 amrex::MultiFab* mf_rv,
817 amrex::MultiFab& S_old,
818 amrex::MultiFab& S_new,
819 amrex::MultiFab& mf_W, amrex::MultiFab& mf_DC,
820 /* MF mf_FC? */
821 const amrex::MultiFab* mf_z_r,
822 const amrex::MultiFab* mf_z_w,
823 const amrex::MultiFab* mf_h,
824 const amrex::MultiFab* mf_pm,
825 const amrex::MultiFab* mf_pn,
826 const amrex::MultiFab* mf_sustr,
827 const amrex::MultiFab* mf_svstr,
828 const amrex::MultiFab* mf_bustr,
829 const amrex::MultiFab* mf_bvstr,
830 const amrex::MultiFab* mf_msku,
831 const amrex::MultiFab* mf_mskv,
832 const int iic, const int nfirst,
833 const int nnew, int nstp, int nrhs,
834 int N, const amrex::Real dt_lev);
835
836 /** \brief Prestep advection calculations for the tracers */
837 void prestep_t_advection (int lev, const amrex::Box& tbx,
838 const amrex::Box& gbx,
839 const amrex::Array4<amrex::Real >& tempold,
840 const amrex::Array4<amrex::Real >& tempcache,
841 const amrex::Array4<amrex::Real >& Hz,
842 const amrex::Array4<amrex::Real >& Huon,
843 const amrex::Array4<amrex::Real >& Hvom,
844 const amrex::Array4<amrex::Real >& W,
845 const amrex::Array4<amrex::Real >& DC,
846 const amrex::Array4<amrex::Real >& FC,
847 const amrex::Array4<amrex::Real >& sstore,
848 const amrex::Array4<amrex::Real const>& z_w,
849 const amrex::Array4<amrex::Real const>& h,
850 const amrex::Array4<amrex::Real const>& pm,
851 const amrex::Array4<amrex::Real const>& pn,
852 const amrex::Array4<amrex::Real const>& msku,
853 const amrex::Array4<amrex::Real const>& mskv,
854 const amrex::Array4<int const>& river_pos,
855 const amrex::Array4<amrex::Real const>& river_source,
856 int iic, int ntfirst, int nrhs, int N,
857 const amrex::Real dt_lev);
858
859 /** \brief RHS terms for tracer */
860 void rhs_t_3d (int lev,
861 const amrex::Box& bx,
862 const amrex::Array4<amrex::Real >& t,
863 const amrex::Array4<amrex::Real const>& tempstore,
864 const amrex::Array4<amrex::Real const>& Huon,
865 const amrex::Array4<amrex::Real const>& Hvom,
866 const amrex::Array4<amrex::Real const>& Hz,
867 const amrex::Array4<amrex::Real const>& pn,
868 const amrex::Array4<amrex::Real const>& pm,
869 const amrex::Array4<amrex::Real const>& W,
870 const amrex::Array4<amrex::Real >& FC,
871 const amrex::Array4<amrex::Real const>& mskr,
872 const amrex::Array4<amrex::Real const>& msku,
873 const amrex::Array4<amrex::Real const>& mskv,
874 const amrex::Array4<int const>& river_pos,
875 const amrex::Array4<amrex::Real const>& river_source,
876 int nrhs, int nnew, int N, const amrex::Real dt_lev,
877 const amrex::Array4<amrex::Real>& fx_reg = amrex::Array4<amrex::Real>(),
878 const amrex::Array4<amrex::Real>& fy_reg = amrex::Array4<amrex::Real>());
879
880 /** \brief RHS terms for 3D momentum */
881 void rhs_uv_3d (int lev,
882 const amrex::Box& xbx,
883 const amrex::Box& ybx,
884 const amrex::Array4<amrex::Real const>& uold,
885 const amrex::Array4<amrex::Real const>& vold,
886 const amrex::Array4<amrex::Real >& ru,
887 const amrex::Array4<amrex::Real >& rv,
888 const amrex::Array4<amrex::Real >& rufrc,
889 const amrex::Array4<amrex::Real >& rvfrc,
890 const amrex::Array4<amrex::Real const>& sustr,
891 const amrex::Array4<amrex::Real const>& svstr,
892 const amrex::Array4<amrex::Real const>& bustr,
893 const amrex::Array4<amrex::Real const>& bvstr,
894 const amrex::Array4<amrex::Real const>& Huon,
895 const amrex::Array4<amrex::Real const>& Hvom,
896 const amrex::Array4<amrex::Real const>& pm,
897 const amrex::Array4<amrex::Real const>& pn,
898 const amrex::Array4<amrex::Real const>& W,
899 const amrex::Array4<amrex::Real >& FC,
900 int nrhs, int N);
901
902 /** \brief RHS terms for 2D momentum */
903 void rhs_uv_2d (int lev,
904 const amrex::Box& xbx,
905 const amrex::Box& ybx,
906 const amrex::Array4<amrex::Real const>& uold,
907 const amrex::Array4<amrex::Real const>& vold,
908 const amrex::Array4<amrex::Real >& ru,
909 const amrex::Array4<amrex::Real >& rv,
910 const amrex::Array4<amrex::Real const>& Duon,
911 const amrex::Array4<amrex::Real const>& Dvom,
912 const int nrhs);
913
914 /** \brief Wrapper around equation of state calculation */
915 void rho_eos (const amrex::Box& bx,
916 const amrex::Array4<amrex::Real const>& state,
917 const amrex::Array4<amrex::Real >& rho,
918 const amrex::Array4<amrex::Real >& rhoA,
919 const amrex::Array4<amrex::Real >& rhoS,
920 const amrex::Array4<amrex::Real >& bvf,
921 const amrex::Array4<amrex::Real >& alpha,
922 const amrex::Array4<amrex::Real >& beta,
923 const amrex::Array4<amrex::Real const>& Hz,
924 const amrex::Array4<amrex::Real const>& z_w,
925 const amrex::Array4<amrex::Real const>& z_r,
926 const amrex::Array4<amrex::Real const>& h,
927 const amrex::Array4<amrex::Real const>& mskr,
928 const int N);
929
930 /** \brief Calculate density and related quantities from linear equation of state */
931 void lin_eos (const amrex::Box& bx,
932 const amrex::Array4<amrex::Real const>& state,
933 const amrex::Array4<amrex::Real >& rho,
934 const amrex::Array4<amrex::Real >& rhoA,
935 const amrex::Array4<amrex::Real >& rhoS,
936 const amrex::Array4<amrex::Real >& bvf,
937 const amrex::Array4<amrex::Real const>& Hz,
938 const amrex::Array4<amrex::Real const>& z_w,
939 const amrex::Array4<amrex::Real const>& z_r,
940 const amrex::Array4<amrex::Real const>& h,
941 const amrex::Array4<amrex::Real const>& mskr,
942 const int N);
943
944 /** \brief Calculate density and related quantities from nonlinear equation of state */
945 void nonlin_eos (const amrex::Box& bx,
946 const amrex::Array4<amrex::Real const>& state,
947 const amrex::Array4<amrex::Real >& rho,
948 const amrex::Array4<amrex::Real >& rhoA,
949 const amrex::Array4<amrex::Real >& rhoS,
950 const amrex::Array4<amrex::Real >& bvf,
951 const amrex::Array4<amrex::Real >& alpha,
952 const amrex::Array4<amrex::Real >& beta,
953 const amrex::Array4<amrex::Real const>& Hz,
954 const amrex::Array4<amrex::Real const>& z_w,
955 const amrex::Array4<amrex::Real const>& z_r,
956 const amrex::Array4<amrex::Real const>& h,
957 const amrex::Array4<amrex::Real const>& mskr,
958 const int N);
959
960 /** \brief Calculate pressure gradient */
961 void prsgrd (const amrex::Box& bx,
962 const amrex::Box& gbx,
963 const amrex::Box& utbx,
964 const amrex::Box& vtbx,
965 const amrex::Array4<amrex::Real >& ru,
966 const amrex::Array4<amrex::Real >& rv,
967 const amrex::Array4<amrex::Real const>& pn,
968 const amrex::Array4<amrex::Real const>& pm,
969 const amrex::Array4<amrex::Real const>& rho,
970 const amrex::Array4<amrex::Real >& FC,
971 const amrex::Array4<amrex::Real const>& Hz,
972 const amrex::Array4<amrex::Real const>& z_r,
973 const amrex::Array4<amrex::Real const>& z_w,
974 const amrex::Array4<amrex::Real const>& msku,
975 const amrex::Array4<amrex::Real const>& mskv,
976 const int nrhs, const int N);
977
978 /** \brief Update velocities or tracers with diffusion/viscosity
979 * as the last part of the prestep */
980 void prestep_diffusion (const amrex::Box& bx,
981 const amrex::Box& gbx,
982 const int ioff, const int joff,
983 const amrex::Array4<amrex::Real >& vel,
984 const amrex::Array4<amrex::Real const>& vel_old,
985 const amrex::Array4<amrex::Real >& rvel,
986 const amrex::Array4<amrex::Real const>& Hz,
987 const amrex::Array4<amrex::Real const>& Akv,
988 const amrex::Array4<amrex::Real >& FC,
989 const amrex::Array4<amrex::Real const>& sstr,
990 const amrex::Array4<amrex::Real const>& bstr,
991 const amrex::Array4<amrex::Real const>& z_r,
992 const amrex::Array4<amrex::Real const>& pm,
993 const amrex::Array4<amrex::Real const>& pn,
994 const int iic, const int ntfirst, const int nnew, int nstp, int nrhs, int N,
995 const amrex::Real lambda, const amrex::Real dt_lev);
996
997 /** \brief Calculate effects of vertical viscosity or diffusivity */
998 void vert_visc_3d (const amrex::Box& bx,
999 const int ioff, const int joff,
1000 const amrex::Array4<amrex::Real >& phi,
1001 const amrex::Array4<amrex::Real const>& Hz,
1002 const amrex::Array4<amrex::Real >& Hzk,
1003 const amrex::Array4<amrex::Real >& AK,
1004 const amrex::Array4<amrex::Real const>& Akv,
1005 const amrex::Array4<amrex::Real >& BC,
1006 const amrex::Array4<amrex::Real >& DC,
1007 const amrex::Array4<amrex::Real >& FC,
1008 const amrex::Array4<amrex::Real >& CF,
1009 const int nnew, const int N,
1010 const amrex::Real dt_lev);
1011
1012 /** \brief Correct mass flux */
1013 void update_massflux_3d (int lev, const amrex::Box& bx,
1014 const int ioff, const int joff,
1015 const amrex::Array4<amrex::Real >& phi,
1016 const amrex::Array4<amrex::Real >& phibar,
1017 const amrex::Array4<amrex::Real >& Hphi,
1018 const amrex::Array4<amrex::Real const>& Hz,
1019 const amrex::Array4<amrex::Real const>& pm_or_pn,
1020 const amrex::Array4<amrex::Real const>& Dphi1,
1021 const amrex::Array4<amrex::Real const>& Dphi2,
1022 const amrex::Array4<amrex::Real >& DC,
1023 const amrex::Array4<amrex::Real >& FC,
1024 const amrex::Array4<amrex::Real const>& msk,
1025 const int nnew);
1026
1027 /** \brief Adjust 3D momentum variables based on vertical mean momentum */
1028 void vert_mean_3d (const amrex::Box& bx,
1029 const int ioff, const int joff,
1030 const amrex::Array4<amrex::Real >& phi,
1031 const amrex::Array4<amrex::Real const>& Hz,
1032 const amrex::Array4<amrex::Real const>& Dphi_avg1,
1033 const amrex::Array4<amrex::Real >& DC,
1034 const amrex::Array4<amrex::Real >& CF,
1035 const amrex::Array4<amrex::Real const>& pm_or_pn,
1036 const amrex::Array4<amrex::Real const>& msk,
1037 const int nnew, const int N);
1038
1039 /** \brief Harmonic viscosity */
1040 void uv3dmix (const amrex::Box& xbx,
1041 const amrex::Box& ybx,
1042 const amrex::Array4<amrex::Real >& u,
1043 const amrex::Array4<amrex::Real >& v,
1044 const amrex::Array4<amrex::Real const>& uold,
1045 const amrex::Array4<amrex::Real const>& vold,
1046 const amrex::Array4<amrex::Real >& rufrc,
1047 const amrex::Array4<amrex::Real >& rvfrc,
1048 const amrex::Array4<amrex::Real const>& visc2_p,
1049 const amrex::Array4<amrex::Real const>& visc2_r,
1050 const amrex::Array4<amrex::Real const>& Hz,
1051 const amrex::Array4<amrex::Real const>& pm,
1052 const amrex::Array4<amrex::Real const>& pn,
1053 const amrex::Array4<amrex::Real const>& mskp,
1054 int nrhs, int nnew,
1055 const amrex::Real dt_lev);
1056
1057 /** \brief Wrapper for harmonic diffusivity for tracers */
1058 void t3dmix2 (const amrex::Box& bx,
1059 const amrex::Array4<amrex::Real >& state,
1060 const amrex::Array4<amrex::Real >& state_rhs,
1061 const amrex::Array4<amrex::Real const>& diff2,
1062 const amrex::Array4<amrex::Real const>& Hz,
1063 const amrex::Array4<amrex::Real const>& z_r,
1064 const amrex::Array4<amrex::Real const>& pm,
1065 const amrex::Array4<amrex::Real const>& pn,
1066 const amrex::Array4<amrex::Real const>& msku,
1067 const amrex::Array4<amrex::Real const>& mskv,
1068 const amrex::Real dt_lev,
1069 const int ncomp, const int N);
1070
1071 /** \brief Harmonic diffusivity for tracers along S-coordinate level surfaces */
1072 void t3dmix2_s(const amrex::Box& bx,
1073 const amrex::Array4<amrex::Real >& state,
1074 const amrex::Array4<amrex::Real >& state_rhs,
1075 const amrex::Array4<amrex::Real const>& diff2,
1076 const amrex::Array4<amrex::Real const>& Hz,
1077 const amrex::Array4<amrex::Real const>& pm,
1078 const amrex::Array4<amrex::Real const>& pn,
1079 const amrex::Array4<amrex::Real const>& msku,
1080 const amrex::Array4<amrex::Real const>& mskv,
1081 const amrex::Real dt_lev, const int ncomp);
1082
1083 /** \brief Harmonic diffusivity for tracers along geopotential surfaces */
1084 void t3dmix2_geo (const amrex::Box& bx,
1085 const amrex::Array4<amrex::Real >& state,
1086 const amrex::Array4<amrex::Real >& state_rhs,
1087 const amrex::Array4<amrex::Real const>& diff2,
1088 const amrex::Array4<amrex::Real const>& Hz,
1089 const amrex::Array4<amrex::Real const>& z_r,
1090 const amrex::Array4<amrex::Real const>& pm,
1091 const amrex::Array4<amrex::Real const>& pn,
1092 const amrex::Array4<amrex::Real const>& msku,
1093 const amrex::Array4<amrex::Real const>& mskv,
1094 const amrex::Real dt_lev,
1095 const int ncomp, const int N);
1096
1097 /** \brief Calculate Coriolis terms */
1098 void coriolis (const amrex::Box& xbx,
1099 const amrex::Box& ybx,
1100 const amrex::Array4<amrex::Real const>& uold,
1101 const amrex::Array4<amrex::Real const>& vold,
1102 const amrex::Array4<amrex::Real >& ru,
1103 const amrex::Array4<amrex::Real >& rv,
1104 const amrex::Array4<amrex::Real const>& Hz,
1105 const amrex::Array4<amrex::Real const>& fomn,
1106 int nrhs, int nr);
1107
1108 /** \brief Calculate curvilinear advection terms */
1109 void curvilinear (const amrex::Box& bx,
1110 const amrex::Box& xbx,
1111 const amrex::Box& ybx,
1112 const amrex::Array4<amrex::Real const>& uold,
1113 const amrex::Array4<amrex::Real const>& vold,
1114 const amrex::Array4<amrex::Real >& ru,
1115 const amrex::Array4<amrex::Real >& rv,
1116 const amrex::Array4<amrex::Real const>& Hz,
1117 const amrex::Array4<amrex::Real const>& dndx,
1118 const amrex::Array4<amrex::Real const>& dmde,
1119 int nrhs, int nr);
1120
1121 /** \brief Shrink an x- or y-nodal momentum tilebox to the faces ROMS nudges
1122 *
1123 * ROMS nudges momentum toward climatology over i=IstrU..Iend (j=JstrV..Jend), which
1124 * excludes the u-face on the western and eastern domain edges (v-face on the southern
1125 * and northern edges). This returns the part of \p nodal_bx that survives that
1126 * exclusion. Under EW_PERIODIC (NS_PERIODIC) ROMS sets IstrU=Istr (JstrV=Jstr) and
1127 * nudges every face, so a periodic direction is left alone.
1128 *
1129 * @param[in] nodal_bx box from MFIter::nodaltilebox(dir)
1130 * @param[in] dir direction the box is nodal in (0 for u, 1 for v)
1131 * @param[in] domain cell-centered problem domain at this level
1132 * @param[in] is_periodic whether \p dir is periodic
1133 */
1134 static amrex::Box clim_nudg_momentum_box (const amrex::Box& nodal_bx,
1135 int dir,
1136 const amrex::Box& domain,
1137 bool is_periodic);
1138
1139 /** \brief Apply climatology nudging */
1140 void apply_clim_nudg (const amrex::Box& bx,
1141 int ioff, int joff,
1142 const amrex::Array4<amrex::Real >& var,
1143 const amrex::Array4<amrex::Real const>& var_old,
1144 const amrex::Array4<amrex::Real const>& var_clim,
1145 const amrex::Array4<amrex::Real const>& clim_coeff,
1146 const amrex::Array4<amrex::Real const>& Hz,
1147 const amrex::Array4<amrex::Real const>& pm,
1148 const amrex::Array4<amrex::Real const>& pn,
1149 const amrex::Real dt_lev = zero);
1150
1151 /** \brief Set 2D momentum arrays from 3D momentum */
1152 void set_2darrays (int lev);
1153
1154 /** \brief Set Zt_avg1 to zeta */
1155 void set_zeta_average (int lev);
1156
1157 /** \brief Initialize zeta from file or analytic */
1158 void set_zeta (int lev);
1159
1160 /** \brief Copy over zeta data that has been averaged down from high res */
1161 void set_zeta_averaged_down (int lev);
1162
1163 /** \brief Initialize bathymetry from file or analytic */
1164 void set_bathymetry (int lev);
1165
1166 /** \brief Copy over bathymetry data that has been averaged down from high resolution
1167 * input netcdf file */
1169
1170 /** \brief Initialize Coriolis factor from file or analytic */
1171 void set_coriolis (int lev);
1172
1173 /** \brief Initialize land-sea masks from file or analytic */
1174 void set_masks (int lev);
1175
1176 /** \brief Copy this level's land-sea mask out of the full-domain mask that was coarsened
1177 * down from hires_grid_level */
1178 void set_masks_averaged_down (int lev);
1179
1180 /** \brief Coarsen the full-domain rho-mask from crse_lev+1 onto crse_lev, grow cells
1181 * included, by the rule that a coarse cell is land only if all its fine cells are land */
1183
1184 /** \brief Coarsen the full-domain bathymetry from crse_lev+1 onto crse_lev, grow cells
1185 * included, weighted by the land/sea mask */
1187
1188 /** \brief Inject the full-domain rho-mask from fine_lev-1 onto fine_lev, piecewise
1189 * constant, grow cells included */
1191
1192 /** \brief Make sure the full-domain rho-mask exists on levels 0 through top_lev */
1194
1195 /** \brief Rebuild the u-, v- and psi-point masks from vec_mskr and fill their ghosts */
1196 void update_nodal_masks (int lev);
1197
1198 /** \brief Make sure the coarse masks the average-down kernels read sit on the coarsened
1199 * layout of level crse_lev+1, rebuilding them if a regrid has moved it */
1200 void update_avgdown_masks (int crse_lev);
1201
1202 /** \brief Drop the cached average-down masks of every level pair that involves lev */
1203 void clear_avgdown_masks (int lev);
1204
1205 /** \brief Check every level pair's masks against each other, and every level's mask
1206 * values, reporting according to remora.mask_consistency */
1207 void check_mask_consistency ();
1208
1209 /** \brief Calculate vertical stretched coordinates */
1210 void stretch_transform (int lev);
1211
1212 /** \brief Calculate z_r and z_w on full-domain arrays at a level not yet created */
1213 void stretch_transform_full_domain (int lev, const amrex::MultiFab& mf_h,
1214 const amrex::MultiFab& mf_zeta,
1215 amrex::MultiFab& mf_z_r, amrex::MultiFab& mf_z_w);
1216
1217 /** \brief Initialize vertical mixing coefficients from file or analytic */
1218 void init_set_vmix (int lev);
1219 /** \brief Set vertical mixing coefficients from analytic */
1220 void set_analytic_vmix (int lev);
1221 /** \brief Initialize GLS variables */
1223 /** \brief Prestep for GLS calculation */
1224 void gls_prestep (int lev, amrex::MultiFab* mf_gls, amrex::MultiFab* mf_tke,
1225 amrex::MultiFab& mf_W,
1226 amrex::MultiFab* mf_msku, amrex::MultiFab* mf_mskv,
1227 const int nstp, const int nnew, const int iic, const int ntfirst,
1228 const int N, const amrex::Real dt_lev);
1229 /** \brief Corrector step for GLS calculation */
1230 void gls_corrector (int lev, amrex::MultiFab* mf_gls, amrex::MultiFab* mf_tke,
1231 amrex::MultiFab& mf_W, amrex::MultiFab* mf_Akv, amrex::MultiFab* mf_Akt,
1232 amrex::MultiFab* mf_Akk, amrex::MultiFab* mf_Akp,
1233 amrex::MultiFab* mf_mskr,
1234 amrex::MultiFab* mf_msku, amrex::MultiFab* mf_mskv,
1235 const int nstp, const int nnew,
1236 const int N, const amrex::Real dt_lev);
1237
1238 /** \brief Scale RHS momentum variables by 1/cell area, needed before FillPatch to different levels*/
1239 void scale_rhs_vars (int lev);
1240 /** \brief Scale RHS momentum variables by cell area, needed after FillPatch to different levels*/
1241 void scale_rhs_vars_inv (int lev);
1242
1243 /** \brief Initialize or calculate surface momentum flux from file or analytic */
1244 void set_smflux (int lev);
1245
1246 /** \brief Initialize or calculate wind speed and other surface state vars from file or analytic */
1247 void set_surface_state (int lev);
1248
1249 /** \brief Initialize horizontal mixing coefficients */
1250 void set_hmixcoef (int lev);
1251
1252 /** \brief Initialize or calculate bottom drag */
1253 void set_drag (int lev);
1254
1255 /** \brief Set weights for averaging 3D variables to 2D */
1256 void set_weights (int lev);
1257
1258 /** \brief Fill the physical boundary conditions for cell-centered velocity (diagnostic only) */
1259 void FillBdyCCVels (int lev, amrex::MultiFab& mf_cc_vel);
1260
1261 /** \brief Fill a new MultiFab by copying in phi from valid region and filling ghost cells */
1262 void FillPatch (int lev, amrex::Real time,
1263 amrex::MultiFab& mf_to_be_filled,
1264 amrex::Vector<amrex::MultiFab*> const& mfs,
1265 const int bccomp,
1266 const int bdy_var_type = BdyVars::null,
1267 const int icomp=0,
1268 const bool fill_all=true,
1269 const bool fill_set=false,
1270 const int n_not_fill=0,
1271 const int icomp_calc=0,
1272 const amrex::Real dt = zero,
1273 const amrex::MultiFab& mf_calc = amrex::MultiFab(),
1274 amrex::Vector<amrex::MultiFab*> const& mfs_crse_old = {},
1275 amrex::Vector<amrex::MultiFab*> const& mfs_crse_new = {});
1276
1277 /** \brief Fill a new MultiFab by copying in phi from valid region and filling ghost cells without applying boundary conditions */
1278 void FillPatchNoBC (int lev, amrex::Real time,
1279 amrex::MultiFab& mf_to_be_filled,
1280 amrex::Vector<amrex::MultiFab*> const& mfs,
1281 const int bdy_var_type = BdyVars::null,
1282 const int icomp=0,
1283 const bool fill_all=true,
1284 const bool fill_set=false,
1285 amrex::Vector<amrex::MultiFab*> const& mfs_crse_old = {},
1286 amrex::Vector<amrex::MultiFab*> const& mfs_crse_new = {});
1287 /** \brief Fill boundary data from netcdf file */
1288 void fill_from_bdyfiles (int lev,
1289 amrex::MultiFab& mf_to_fill,
1290 const amrex::MultiFab& mf_mask,
1291 const amrex::Real time,
1292 const int bccomp,
1293 const int bdy_var_type,
1294 const int icomp_to_fill,
1295 const int icomp_calc = 0,
1296 const amrex::MultiFab& mf_calc = amrex::MultiFab(),
1297 const amrex::Real = zero);
1298
1299 /** \brief fill an entire multifab by interpolating from the coarser level
1300 * using the piecewise constant interpolater */
1301 void FillCoarsePatchPC (int lev, amrex::Real time, amrex::MultiFab* mf_fine,
1302 amrex::MultiFab* mf_crse,
1303 const int bccomp,
1304 const int bdy_var_type = BdyVars::null,
1305 const int icomp = 0,
1306 const bool fill_all = true,
1307 const int n_not_fill=0,
1308 const int icomp_calc=0,
1309 const amrex::Real dt = zero,
1310 const amrex::MultiFab& mf_calc = amrex::MultiFab());
1311
1312 /** \brief fill an entire multifab by interpolating from the coarser level */
1313 void FillCoarsePatch (int lev, amrex::Real time, amrex::MultiFab* mf_fine,
1314 amrex::MultiFab* mf_crse,
1315 const int bccomp,
1316 const int bdy_var_type = BdyVars::null,
1317 const int icomp = 0,
1318 const bool fill_all = true,
1319 const int n_not_fill=0,
1320 const int icomp_calc=0,
1321 const amrex::Real dt = zero,
1322 const amrex::MultiFab& mf_calc = amrex::MultiFab());
1323
1324 /** \brief fill an entire multifab by interpolating from the coarser level,
1325 * explicitly specifying interpolator to use */
1326 void FillCoarsePatchMap (int lev, amrex::Real time, amrex::MultiFab* mf_fine,
1327 amrex::MultiFab* mf_crse,
1328 const int bccomp,
1329 const int bdy_var_type = BdyVars::null,
1330 const int icomp = 0,
1331 const bool fill_all = true,
1332 const int n_not_fill=0,
1333 const int icomp_calc=0,
1334 const amrex::Real dt = zero,
1335 const amrex::MultiFab& mf_calc = amrex::MultiFab(),
1336 amrex::Interpolater* mapper = nullptr);
1337
1338 /** \brief initialize and calculate stretch coefficients */
1339 void init_stretch_coeffs ();
1340 /** \brief calculate vertical stretch coefficients */
1341 void calc_stretch_coeffs ();
1342
1343 /** \brief Calculate Coriolis parameters from beta plane parametrization */
1344 void init_beta_plane_coriolis (int lev);
1345
1346 /** \brief Full domain bathymetry data initialization from analytic */
1348
1349 /** \brief Full domain land-sea mask initialization from analytic */
1351
1352 /** \brief Problem initialization from averaged-down high resolution data */
1354 /** \brief Problem initialization from NetCDF file */
1355 void init_data_from_netcdf (int lev);
1356 /** \brief Biology initialization from NetCDF file */
1357 void init_biology_from_netcdf (int lev);
1358 /** \brief Passive (dye) scalar initialization from NetCDF file. Called from
1359 * init_data_from_netcdf: dye follows remora.ic_type rather than having
1360 * a source flag of its own. */
1361 void init_scalars_from_netcdf (int lev);
1362
1363 /** \brief Initialize biology tracers from whichever source
1364 * remora.biology_ic_type selects. Call after the physical fields
1365 * exist: the analytic profiles are functions of temperature. */
1366 void init_biology_ic (int lev);
1367
1368 /** \brief Full-domain counterpart of init_biology_ic, for the
1369 * hires_init_level average-down path. */
1371 /** \brief High resolution roblem initialization from NetCDF file */
1373 /** \brief Full-domain high-res biology initialization from NetCDF file */
1375 /** \brief Full-domain high-res passive (dye) scalar initialization from NetCDF file */
1377 /** \brief Boundary data initialization from NetCDF file */
1378 void init_bdry_from_netcdf (int lev);
1379 /** \brief Mask data initialization from NetCDF file */
1380 void init_masks_from_netcdf (int lev);
1381 /** \brief Full domain high-res mask data initialization from NetCDF file */
1383 /** \brief Bathymetry data initialization from NetCDF file */
1385 /** \brief Full domain high-res bathymetry data initialization from NetCDF file */
1387
1388 /** \brief Grid variable initialization from NetCDF file */
1390 /** \brief Full domain high-res grid variable initialization from NetCDF file */
1392
1393 /** \brief Extrapolate grid metrics to edge of MultiFab */
1394 void extrapolate_metric_to_physical_boundaries(amrex::MultiFab& mf, const amrex::Geometry& geom);
1395
1396 /** \brief Sea-surface height data initialization from NetCDF file */
1397 void init_zeta_from_netcdf (int lev);
1398 /** \brief Full-domain high res sea-surface height data initialization from NetCDF file */
1400 /** \brief Coriolis parameter data initialization from NetCDF file */
1401 void init_coriolis_from_netcdf (int lev);
1402 /** \brief Climatology nudging coefficient initialization from NetCDF file */
1404 /** \brief Wrapper to initialize climatology nudging coefficient */
1405 void init_clim_nudg_coeff (int lev);
1406 void init_riv_pos_from_netcdf (int lev);
1407
1408 /** \brief the DistributionMapping every full-domain multifab is built on.
1409 * Each of those covers the domain in a single box, so the map holds one entry, and which
1410 * rank it names is whichever holds the least fab memory when it is built. Building one per
1411 * allocator therefore put the mask and the data it weights on different ranks under MPI.
1412 * Empty until full_domain_dmap first needs it. **/
1413 amrex::DistributionMapping dm_full_domain;
1414
1415 /** \brief The shared full-domain DistributionMapping, built on first use */
1416 const amrex::DistributionMapping& full_domain_dmap ();
1417
1418 /** \brief Allocate multifabs for storing full-domain bathymetry and grid vars data */
1420 /** \brief Allocate multifabs for storing full-domain high resolution initial data */
1422
1423 /** \brief Convert data in a multifab from inverse days to inverse seconds */
1424 void convert_inv_days_to_inv_s (amrex::MultiFab*);
1425
1426 /** \brief Mask data arrays before writing output */
1427 void mask_arrays_for_write (int lev, amrex::Real fill_value, amrex::Real fill_where);
1428
1429 /** \brief Average down from level lev+1 to lev in mf, including grow cells */
1430 void average_down_with_grow_cells(int lev, amrex::Vector<std::unique_ptr<amrex::MultiFab>>& mf,
1431 bool use_mask = false);
1432
1433 /** \brief Average one field down a level, weighted by the land/sea mask. */
1434 /** \brief coarse cell mask, 1 where covered by lev+1, with one grow cell */
1435 void build_covered_mask (int crse_lev, amrex::MultiFab& covered);
1436
1437 /** \brief put back the coarse normal-velocity faces on the fine patch's perimeter */
1438 void restore_perimeter_faces (const amrex::MultiFab& saved, amrex::MultiFab& mf,
1439 const amrex::MultiFab& covered, int dir, int ncomp);
1440
1441 void average_down_masked (int crse_lev, const amrex::MultiFab& S_fine,
1442 amrex::MultiFab& S_crse, const amrex::MultiFab& msk_fine,
1443 const amrex::MultiFab& cmsk, int ncomp, int face_dir);
1444
1445 /** \brief Initialize high-resolution initial data, zeta included, from analytic functions */
1447
1460
1461 ///@{
1462 /** \brief Accessors for the ncons-dependent entries of BdyVars */
1463 int bdy_cons (int icomp) const noexcept { return BdyVars::cons(icomp); }
1468 ///@}
1469
1470 /** \brief Number of passive (dye) scalars in the state, not counting biology tracers.
1471 *
1472 * Zero means the state has no dye component at all, so Tracer_comp is either the first
1473 * biology tracer or one past the end of cons. Problem setups that initialize a dye have
1474 * to test this rather than nComp(), which cannot tell a dye apart from a biology tracer.
1475 */
1477
1478
1479#ifdef REMORA_USE_NETCDF
1481#endif
1482
1483private:
1484
1485 ///////////////////////////
1486 // private member functions
1487 ///////////////////////////
1488
1489 /** \brief read in some parameters from inputs file */
1490 void ReadParameters();
1491
1492 /** \brief Build runtime scalar names after nscalar is known */
1493 void init_scalar_metadata();
1494
1495 /** \brief set covered coarse cells to be the average of overlying fine cells */
1496 void AverageDown ();
1497
1498 /** \brief Read in boundary parameters from input file and set up data structures */
1499 void init_bcs();
1500
1501 /** \brief Initialize initial problem data from analytic functions */
1502 void init_analytic(int lev);
1503 /** \brief Coordinate arrays of level lev, for the prob functions */
1504 ProbCoords prob_coords (int lev) const;
1505
1506 /** \brief Allocate MultiFabs for state and evolution variables */
1507 void init_stuff (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
1508
1509 /** \brief Allocate MultiFabs for masks */
1510 void init_masks (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
1511
1512 /** \brief Resize variable containers to accommodate data on levels 0 to max_lev */
1513 void resize_stuff (int lev);
1514
1515 /** \brief more flexible version of AverageDown() that lets you average down across multiple levels */
1516 void AverageDownTo (int crse_lev);
1517
1518 /** \brief Construct FillPatchers */
1520
1521 /** \brief Define FillPatchers */
1522 void Define_REMORAFillPatchers (int lev);
1523
1524 /** \brief utility to copy in data from old and/or new state into another multifab */
1525 TimeInterpolatedData GetDataAtTime (int lev, amrex::Real time);
1526
1527 /** \brief advance a level by dt, includes a recursive call for finer levels */
1528 void timeStep (int lev, amrex::Real time, int iteration);
1529
1530 /** \brief advance all levels by dt, loops over finer levels */
1531 void timeStepML (amrex::Real time, int iteration);
1532
1533 /** \brief a wrapper for estTimeStep() */
1534 void ComputeDt ();
1535
1536 /** \brief report the per-level slow/fast timestep hierarchy; call after ComputeDt */
1537 void print_timestep_hierarchy () const;
1538
1539 /** \brief size nsubsteps and set how many steps each level takes per parent step */
1540 void set_nsubsteps (int nlevs_max);
1541
1542 /** \brief get plotfile name */
1543 std::string PlotFileName (int lev) const;
1544
1545 /* set which variables and derived quantities go into plotfiles */
1546 void set2DPlotVariables (const std::string& pp_plot_var_names_2d);
1547 void set3DPlotVariables (const std::string& pp_plot_var_names_3d);
1548
1549 /* append variables to plot */
1550 void append2DPlotVariables (const std::string& pp_plot_var_names_2d);
1551 void append3DPlotVariables (const std::string& pp_plot_var_names_3d);
1552
1553#ifdef REMORA_USE_NETCDF
1554 /** \brief Write plotfile using NetCDF (wrapper) */
1555 void WriteNCPlotFile (int istep, amrex::MultiFab const* plotMF, int lev = 0);
1556
1557 /** \brief Write a particular NetCDF plotfile */
1559 amrex::MultiFab const* plotMF,
1561 bool is_history);
1562
1563 /** \brief Write MultiFab in NetCDF format */
1564 void WriteNCMultiFab (const amrex::FabArray<amrex::FArrayBox> &fab,
1565 const std::string& name,
1566 bool set_ghost = false) const;
1567
1568 /** \brief Read MultiFab in NetCDF format */
1569 void ReadNCMultiFab (amrex::FabArray<amrex::FArrayBox> &fab,
1570 const std::string &name,
1571 int coordinatorProc = amrex::ParallelDescriptor::IOProcessorNumber(),
1572 int allow_empty_mf = 0);
1573
1574 /** \brief Whether to output NetCDF files as a single history file with several time steps */
1576
1577 /** \brief Data container for u-component surface momentum flux read from file */
1578 std::unique_ptr<NCTimeSeries> sustr_data_from_file;
1579 /** \brief Data container for v-component surface momentum flux read from file */
1580 std::unique_ptr<NCTimeSeries> svstr_data_from_file;
1581 /** \brief Data container for u-direction wind read from file */
1582 std::unique_ptr<NCTimeSeries> Uwind_data_from_file;
1583 /** \brief Data container for v-direction wind read from file */
1584 std::unique_ptr<NCTimeSeries> Vwind_data_from_file;
1585 /** \brief Data container for air temperature read from file */
1586 std::unique_ptr<NCTimeSeries> Tair_data_from_file;
1587 /** \brief Data container for specific humidity read from file */
1588 std::unique_ptr<NCTimeSeries> qair_data_from_file;
1589 /** \brief Data container for air pressure read from file */
1590 std::unique_ptr<NCTimeSeries> Pair_data_from_file;
1591 /** \brief Data container for shortwave radiation flux read from file */
1592 std::unique_ptr<NCTimeSeries> srflx_data_from_file;
1593 /** \brief Data container for downward longwave radiation flux read from file */
1594 std::unique_ptr<NCTimeSeries> longwave_down_data_from_file;
1595 /** \brief Data container for precipitation rate read from file */
1596 std::unique_ptr<NCTimeSeries> rain_data_from_file;
1597 /** \brief Data container for cloud cover fraction read from file */
1598 std::unique_ptr<NCTimeSeries> cloud_data_from_file;
1599 /** \brief Data container for evaporation minus precipitation read from file */
1600 std::unique_ptr<NCTimeSeries> EminusP_data_from_file;
1601
1602 /** \brief Data container for ubar climatology data read from file */
1603 std::unique_ptr<NCTimeSeries> ubar_clim_data_from_file;
1604 /** \brief Data container for vbar climatology data read from file */
1605 std::unique_ptr<NCTimeSeries> vbar_clim_data_from_file;
1606 /** \brief Data container for u-velocity climatology data read from file */
1607 std::unique_ptr<NCTimeSeries> u_clim_data_from_file;
1608 /** \brief Data container for v-velocity climatology data read from file */
1609 std::unique_ptr<NCTimeSeries> v_clim_data_from_file;
1610 /** \brief Vector over cons components of climatology data read from file.
1611 *
1612 * Entry icomp is null unless solverChoice.do_cons_clim_nudg[icomp] is set. */
1613 amrex::Vector<std::unique_ptr<NCTimeSeries>> cons_clim_data_from_file;
1614
1615 /** \brief Vector of data containers for scalar data in rivers */
1616 amrex::Vector<std::unique_ptr<NCTimeSeriesRiver>> river_source_cons;
1617 /** \brief Data container for momentum transport in rivers */
1618 std::unique_ptr<NCTimeSeriesRiver> river_source_transport;
1619 /** \brief Data container for vertically integrated momentum transport in rivers */
1620 std::unique_ptr<NCTimeSeriesRiver> river_source_transportbar;
1621
1622 /** \brief Vector over BdyVars of boundary series data containers */
1623 amrex::Vector<amrex::Vector<std::unique_ptr<NCTimeSeriesBoundary>>> boundary_series;
1624
1625#endif // REMORA_USE_NETCDF
1626 /** \brief iMultiFab for river positions; contents are indices of rivers */
1627 amrex::Vector<std::unique_ptr<amrex::iMultiFab>> vec_river_position;
1628 /** \brief Vector over rivers of river direction: 0: u-face; 1: v-face; 2: w-face */
1629 amrex::Gpu::DeviceVector<int> river_direction;
1630
1631
1632#ifdef REMORA_USE_MOAB
1633 /** \brief Initialize connection to MOAB */
1634 void InitMOABMesh();
1635#endif
1636 /** \brief Nudging width at coarse-fine interface */
1637 int cf_width{0};
1638 /** \brief Width for fixing values at coarse-fine interface */
1640 // Fillpatcher classes for coarse-fine boundaries
1641 /** \brief Vector over levels of FillPatchers for scalars */
1642 amrex::Vector<REMORAFillPatcher> FPr_c;
1643 /** \brief Vector over levels of FillPatchers for u (3D) */
1644 amrex::Vector<REMORAFillPatcher> FPr_u;
1645 /** \brief Vector over levels of FillPatchers for v (3D) */
1646 amrex::Vector<REMORAFillPatcher> FPr_v;
1647 /** \brief Vector over levels of FillPatchers for w */
1648 amrex::Vector<REMORAFillPatcher> FPr_w;
1649
1650 // Fillpatcher classes for 2d velocity variables
1651 /** \brief Vector over levels of FillPatchers for ubar (2D) */
1652 amrex::Vector<REMORAFillPatcher> FPr_ubar;
1653 /** \brief Vector over levels of FillPatchers for vbar (2D) */
1654 amrex::Vector<REMORAFillPatcher> FPr_vbar;
1655 /** \brief Vector over levels of FillPatchers for Dubar (2D) */
1656 amrex::Vector<REMORAFillPatcher> FPr_Dubar;
1657 /** \brief Vector over levels of FillPatchers for Dvbar (2D) */
1658 amrex::Vector<REMORAFillPatcher> FPr_Dvbar;
1659
1660 /** \brief write checkpoint file to disk */
1661 void WriteCheckpointFile ();
1662
1663 /** \brief read checkpoint file from disk */
1664 void ReadCheckpointFile ();
1665
1666 /** \brief Read the file passed to remora.restart and use it as an initial condition for the current simulation */
1668
1669 /** \brief Initialize the new-time data at a level from the initial_data MultiFab */
1670 void InitializeLevelFromData (int lev, const amrex::MultiFab& initial_data);
1671
1672 /** \brief utility to skip to next line in Header */
1673 static void GotoNextLine (std::istream& is);
1674
1675 ////////////////
1676 // private data members
1677
1678 /** \brief Pointer to container of analytical functions for problem definition */
1679 std::unique_ptr<ProblemBase> prob = nullptr;
1680
1681 /** \brief how many boxes specified at each level by tagging criteria */
1682 amrex::Vector<int> num_boxes_at_level;
1683 /** \brief how many netcdf input files specified at each level */
1684 amrex::Vector<int> num_files_at_level;
1685 /** \brief the boxes specified at each level by tagging criteria */
1686 amrex::Vector<amrex::Vector<amrex::Box>> boxes_at_level;
1687
1688 /** \brief which step? */
1689 amrex::Vector<int> istep;
1690 /** \brief How many substeps on each level? */
1691 amrex::Vector<int> nsubsteps;
1692 /** \brief new time at each level, in seconds since start_time
1693 *
1694 * Model time is split into a double start_time and a Real elapsed time, as ROMS
1695 * splits DSTART from the time it advances. The solver, the FillPatch time
1696 * interpolation, and the kernels only ever see elapsed time, which stays small
1697 * enough for a float to resolve a timestep. Anything that needs a time on the
1698 * model clock -- forcing and boundary files, the calendar, output time stamps,
1699 * user-given times -- goes through model_time() in double. */
1700 amrex::Vector<amrex::Real> t_new;
1701 /** \brief old time at each level, in seconds since start_time */
1702 amrex::Vector<amrex::Real> t_old;
1703 /** \brief time step at each level */
1704 amrex::Vector<amrex::Real> dt;
1705
1706 /** \brief whether to set boundary conditions by variable rather than just by side */
1708
1709 /** \brief Vector (over level) of functors to apply physical boundary conditions */
1710 amrex::Vector<std::unique_ptr<REMORAPhysBCFunct>> physbcs;
1711
1712 /** \brief array of flux registers for refluxing in multilevel */
1713 amrex::Vector<std::unique_ptr<amrex::YAFluxRegister>> advflux_reg;
1714
1715 /** \brief flux register between lev and lev-1 */
1716 amrex::YAFluxRegister* getAdvFluxReg (int lev) { return advflux_reg[lev].get(); }
1717
1718 /** \brief build or rebuild the flux register between lev and lev-1 */
1719 void define_flux_register (int lev);
1720
1721 ////////////////
1722 // boundary data members
1723
1724 // A BCRec is essentially a 2*DIM integer array storing the boundary
1725 // condition type at each lo/hi walls in each direction. We have one BCRec
1726 // for each component of the cell-centered variables and each velocity component.
1727 /** \brief vector (over BCVars) of BCRecs */
1728 amrex::Vector <amrex::BCRec> domain_bcs_type;
1729 /** \brief GPU vector (over BCVars) of BCRecs */
1730 amrex::Gpu::DeviceVector<amrex::BCRec> domain_bcs_type_d;
1731
1732 /** \brief Array of strings describing domain boundary conditions */
1733 amrex::Array<std::string,2*AMREX_SPACEDIM> domain_bc_type;
1734
1735 /** \brief Array holding the Dirichlet values at walls which need them */
1736 amrex::Vector<amrex::GpuArray<amrex::Real, AMREX_SPACEDIM*2>> m_bc_extdir_vals;
1737
1738 /** \brief Array holding the "physical" boundary condition types (e.g. "inflow") */
1739 amrex::Vector<amrex::GpuArray<REMORA_BC, AMREX_SPACEDIM*2>> phys_bc_type;
1740
1741 /** \brief These are flags that indicate whether we need to read in boundary data from file.
1742 *
1743 * Sized num_bdy_vars()+1; the extra trailing slot is a scratch entry that variables with
1744 * no NetCDF boundary lane (see bdy_index) write into and nothing reads.
1745 */
1746 amrex::Vector<amrex::GpuArray<bool, AMREX_SPACEDIM*2>> phys_bc_need_data;
1747
1748 /** \brief Container to connect boundary data being read in boundary condition containers.
1749 *
1750 * Needed for phys_bc_need_data to work correctly
1751 */
1752 amrex::Vector<int> bdy_index;
1753
1754 /** \brief Step when we last output a plotfile */
1756 /** \brief Simulation time when we last output a plotfile */
1758
1759 /** \brief Step when we last output a checkpoint file */
1761 /** \brief Simulation time when we last output a checkpoint file */
1763 /** \brief Whether to output a plotfile on restart from checkpoint */
1765
1766 ////////////////
1767 // runtime parameters
1768
1769 /** \brief maximum number of steps */
1770 int max_step = std::numeric_limits<int>::max();
1771 /** \brief Whether max_step was set in the inputs; the default above is not a
1772 * distinguishable sentinel */
1773 /** \brief Time to stop, in seconds on the model clock (not since start_time) */
1774 double stop_time = std::numeric_limits<amrex::Real>::max();
1775
1776 /** \brief Time of the start of the simulation, in seconds on the model clock.
1777 *
1778 * Also the origin of t_new and t_old. Double regardless of Real: seconds since a
1779 * calendar epoch outgrow a float's resolution within days. */
1780 double start_time = 0.0;
1781
1782 /** \brief If set, restart from this checkpoint file */
1783 std::string restart_chkfile = "";
1784
1785 /** \brief Number of passive (dye) scalars carried in the state, beyond temperature
1786 * and salinity. Does not count biology tracers. Dye is opt-in: a run
1787 * carries one only when remora.nscalar asks for it. */
1788 int nscalar = 0;
1789 /** \brief Number of biology tracers, set by the active biology model. Zero when no
1790 * biology model is active. */
1791 int nbio = 0;
1792 /** \brief First cons component of the biology block, i.e. Tracer_comp + nscalar.
1793 * The state is laid out as temp, salt, the passive scalars, then biology. */
1795 /** \brief Number of conserved scalars in the state
1796 * (temperature + salt + passive scalars + biology tracers) */
1798 /** \brief Active biology package */
1800 /** \brief Runtime parameters for the Fennel biology package */
1802 /** \brief Source of the biology tracer initial condition, independent of
1803 * remora.ic_type. Default follows ic_type. */
1805 /** \brief Select the native C++ biology kernel (1) or the ROMS Fortran
1806 * bridge oracle (0). Only meaningful when built with
1807 * USE_FENNEL_FORT=TRUE; ignored otherwise. Runtime-controlled so
1808 * the two paths can be compared without a rebuild. */
1810 /** \brief Biology diagnostic verbosity: 0 off, 1 target column, 2 all
1811 * columns. See Source/Biology/Fortran/tag_map.md. */
1813 /** \brief Target column i index for biology_debug = 1 */
1815 /** \brief Target column j index for biology_debug = 1 */
1817
1818 // Time step controls
1819 /** \brief CFL condition */
1820 static amrex::Real cfl;
1821 /** \brief Fraction maximum change in subsequent time steps */
1822 static amrex::Real change_max;
1823 /** \brief User specified fixed baroclinic time step */
1824 static amrex::Real fixed_dt;
1825 /** \brief User specified, number of barotropic steps per baroclinic step */
1826 static int ndtfast;
1827 /** \brief Number of fast steps to take */
1829
1830 /** \brief Whether to substep fine levels in time */
1831 int do_substep = 1;
1832
1833 /** \brief interpolate the parent's barotropic mass flux in time at the coarse-fine
1834 * interface, rather than holding its step average. Off matches most ROMS
1835 * configurations. */
1836 bool time_interp_flux = false;
1837
1838 /** \brief impose the parent's barotropic mass flux on DUon/DVom at the coarse-fine
1839 * interface, rather than relying on the velocity written by set_2d_cf_bcs being
1840 * turned back into the same flux. Off by default: it improves conservation but
1841 * does not cure the two-level barotropic instability seen in Channel_Test. */
1843
1844 /** \brief correct the coarse tracer with the finer level's accumulated advective flux
1845 * at their interface. Only has an effect under remora.do_substep with two-way
1846 * coupling. */
1847 int do_reflux = 1;
1848
1849 /** \brief exclude the coarse-fine perimeter's normal-velocity faces from the fine-to-coarse
1850 * average, as ROMS does. 1 (default) matches ROMS; 0 restores the old behaviour. */
1852
1853 /** \brief re-fill the child's 3D velocity from the parent after the step, so the coarse-fine
1854 * boundary carries the parent's shear profile rather than the one vert_mean_3d left
1855 * there. Diagnostic; off, so it changes no answer unless set. Both drivers do it
1856 * only under this knob -- see the comment in Advance. On the ratio-3 Dogbone it
1857 * moves level-1 x-velocity by 4.1e-3 relative and level 0 by 1.9e-4 after 20
1858 * steps. */
1860 /** \brief 0 = never impose the 2D coarse-fine interface condition, 1 = every fast step,
1861 * 2 = only the first fast step of each baroclinic step.
1862 *
1863 * 1 matches ROMS and is the default: put_refine2d runs once before the barotropic loop,
1864 * but u2dbc_im re-applies the same mass-flux formula on every fast step inside it, so 2
1865 * is only half the ROMS schedule. On the dogbone, 2 helps early and is much worse
1866 * later. */
1869 /** \brief write every leapfrog record of the coarse-fine ghost band, as put_refine2d does
1870 * when it sets zeta(:,:,1:3) and Zt_avg1 to one value; without it those records go
1871 * a whole parent step stale. On by default. Roundoff on the ROMS-matched deck,
1872 * where the fine zeta halo is barely read, but the dominant cost to volume
1873 * conservation on the subcycled dogbone: 2.0e-09 to 2.9e-08 of drift over 20
1874 * steps, volume being the integral of the free surface this writes. ROMS makes
1875 * the same trade. */
1877 /** \brief interpolate the parent in time onto the child's own sub-time, as put_refine2d
1878 * does, rather than freezing it at the end of the parent step. On by default, and
1879 * non-conservative for the same reason as cf_fill_all_kcomp: 1.4e-08 of volume
1880 * drift on its own. */
1882 /** \brief distribute the parent's interface mass flux piecewise-constantly over the fine
1883 * faces under each parent face, as ROMS's get_persisted2d does, instead of with
1884 * the linear tangential variation of AMReX's face interpolator. Both conserve the
1885 * total; they differ in the profile along the interface. On by default: it removes
1886 * the fine level's own excess divergence there. */
1887 int cf_flux_pc = 1;
1888 /** \brief average the fine velocity onto the coarse over ROMS's nine-point stencil
1889 * (fine2coarse2d, half-width (Rscale-1)/2 in both directions) instead of only the
1890 * faces that tile the coarse face. On by default: with cf_flux_pc it takes the
1891 * interface refinement perturbation from 1.29x ROMS's to 1.01x on the matched
1892 * dogbone, the residual 1% closing only with cf_impose_flux, which stays off. Not
1893 * conservative in principle -- the nine-point mean does not preserve transport
1894 * across the interface -- but only about 3e-10 of volume drift in practice, well
1895 * under the free-surface ghost band's cost. */
1897
1898 /** \brief print the imposed coarse-fine interface velocity at this baroclinic step
1899 * (-1 = off). Diagnostic only; the fine level is not in the NetCDF output. */
1901
1902 /** \brief stop that correction driving a tracer negative, as ROMS does. On by default to
1903 * match ROMS; costs exact conservation on any step that clamps. */
1905
1906 /** \brief measure whether fine cell edges tile the coarse ones at a coarse-fine
1907 * interface, which is what makes the imposed mass flux conservative */
1909 /** \brief tolerance for the above */
1910 amrex::Real check_cf_tol = 1.e-12;
1911
1912 /** \brief how often each level regrids the higher levels of refinement (after a level advances that many time steps) */
1913 int regrid_int = 2;
1914
1915 // I/O controls
1916 /** \brief Plotfile prefix */
1917 std::string plot_file_name {"plt_"};
1918 /** \brief Plotfile output interval in iterations */
1919 int plot_int = -1;
1920 /** \brief Plotfile output interval in seconds */
1921 amrex::Real plot_int_time = amrex::Real(-one);
1922 /** \brief Checkpoint file prefix */
1923 std::string check_file {"chk"};
1924 /** \brief Checkpoint output interval in iterations */
1925 int check_int = -1;
1926 /** \brief Checkpoint output interval in seconds */
1927 amrex::Real check_int_time = amrex::Real(-one);
1928
1929 /** \brief Whether to split the netcdf history file into fixed-length chunks */
1931 /** \brief Time steps per netcdf history file. Must be > 0 if chunk_history_file. */
1933 /** \brief Counter for which time index we are writing to in the netcdf history file */
1935
1936 /** \brief Names of 3D variables to output to AMReX plotfile */
1937 amrex::Vector<std::string> plot_var_names_3d;
1938 /** \brief Names of 2D variables to output to AMReX plotfile */
1939 amrex::Vector<std::string> plot_var_names_2d;
1940 /** \brief Names of scalars for plotfile output */
1941 amrex::Vector<std::string> cons_names {"temp", "salt", "tracer"};
1942 // Note that the order of variable names here must match the order in PlotFile.cpp
1943 /** \brief Names of derived fields for 3d plotfile fields */
1944 const amrex::Vector<std::string> derived_names_3d {"vorticity"};
1945 /** \brief Names of derived fields for 2d plotfile fields */
1946 const amrex::Vector<std::string> derived_names_2d {};
1947
1948 /** \brief Container for algorithmic choices */
1950
1951 /** \brief whether plotfile variables should be expanded to a uniform refinement ratio */
1953
1954 /** \brief fill value for masked arrays in amrex plotfiles */
1956 /** \brief fill value for masked arrays in netcdf output */
1957 amrex::Real netcdf_fill_value = amrex::Real(1.0e37);
1958
1959
1960#ifdef REMORA_USE_PARTICLES
1961 /** \brief Particle container with all particle species */
1963
1964 // variables and functions for tracers particles
1965 /** \brief tracer particles that advect with flow */
1967 /** \brief tracer particles that fall with gravity */
1969
1970 /** \brief Read tracer and hydro particles parameters */
1971 void readTracersParams();
1972
1973 /** \brief Initialize tracer and hydro particles */
1974 void initializeTracers ( amrex::ParGDBBase*,
1975 const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
1976
1977 /** \brief Evolve tracers and hydro particles */
1978 void evolveTracers( int lev,
1979 amrex::Real dt,
1980 amrex::Vector<amrex::MultiFab const*>& flow_vel,
1981 const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
1982
1983#endif
1984 /** \brief Verbosity level of output */
1985 static int verbose;
1986
1987 /** \brief Diagnostic sum output interval in number of steps */
1988 static int sum_interval;
1989 /** \brief Diagnostic sum output interval in time */
1990 static amrex::Real sum_per;
1991
1992 /** \brief Minimum number of digits in plotfile name or chunked history file */
1994
1995 /** \brief Whether to write the staggered velocities (not averaged to cell centers) */
1997
1998 /** \brief Whether to write nodal data (Nu_nd) to plotfiles */
1999 static bool plot_nodal_data;
2000
2001 /** \brief Native or NetCDF plotfile output */
2003
2004 /** \brief NetCDF initialization file */
2005 static amrex::Vector<amrex::Vector<std::string>> nc_init_file;
2006 /** \brief NetCDF grid file */
2007 static amrex::Vector<amrex::Vector<std::string>> nc_grid_file;
2008 /** \brief NetCDF boundary data */
2009 static amrex::Vector<std::string> nc_bdry_file;
2010
2011 /** \brief Which level the high resolution bathymetry is at */
2013 /** \brief Grid file for high resolution bathymetry */
2015 /** \brief Box for the full domain at nc_hires_grid_level */
2017
2018 /** \brief Which level the high resolution initialization data is at */
2020 /** \brief Init file for high resolution */
2022 /** \brief Box for the full domain at nc_hires_init_level */
2024
2025 /** \brief Cumulative refinement ratio between level 0 and level i */
2026 amrex::Vector<amrex::IntVect> cum_ref_ratios;
2027
2028 /** \brief NetCDF forcing file(s) */
2029 amrex::Vector<std::string> nc_frc_file;
2030 /** \brief NetCDF river file(s) */
2031 amrex::Vector<std::string> nc_riv_file;
2032
2033 /** \brief NetCDF climatology history file(s) */
2034 amrex::Vector<std::string> nc_clim_his_file;
2035 /** \brief NetCDF climatology coefficient file */
2037
2038 /** \brief Default name of time field for boundary data */
2039 std::string bdry_time_varname = "ocean_time";
2040 /** \brief Name of time fields for boundary data */
2041 amrex::Vector<std::string> bdry_time_name_byvar;
2042
2043 /** \brief Name of time field for ubar climatology data */
2044 std::string clim_ubar_time_varname = "ocean_time";
2045 /** \brief Name of time field for vbar climatology data */
2046 std::string clim_vbar_time_varname = "ocean_time";
2047 /** \brief Name of time field for u climatology data */
2048 std::string clim_u_time_varname = "ocean_time";
2049 /** \brief Name of time field for v climatology data */
2050 std::string clim_v_time_varname = "ocean_time";
2051 /** \brief Vector over cons components of the name of the time field for that
2052 * tracer's climatology data */
2053 amrex::Vector<std::string> clim_cons_time_varname;
2054 /** \brief Name of time field for river time */
2055 std::string riv_time_varname = "river_time";
2056 /** \brief Name of time field for forcing data */
2057 std::string frc_time_varname = "";
2058
2059 /** \brief Set refinement criteria */
2061
2062 /** \brief Reject vertical refinement and accumulate the refinement ratios */
2063 void init_ref_ratios ();
2064
2065 /** \brief Holds info for dynamically generated tagging criteria */
2066 static amrex::Vector<REMORAErrorTag> ref_tags;
2067
2068 /** \brief Mask that zeroes out values on a coarse level underlying grids on the next finest level */
2069 amrex::MultiFab fine_mask;
2070
2071 /** \brief Helper function to determine number of ghost cells */
2073 int
2074 ComputeGhostCells(const int& spatial_order) {
2075 int nGhostCells = 0;
2076 switch (spatial_order) {
2077 case 2:
2078 nGhostCells = 2; // We need this many to compute the eddy viscosity in the ghost cells
2079 break;
2080 case 3:
2081 nGhostCells = 2;
2082 break;
2083 case 4:
2084 nGhostCells = 2;
2085 break;
2086 case 5:
2087 nGhostCells = 3;
2088 break;
2089 case 6:
2090 nGhostCells = 3;
2091 break;
2092 default:
2093 amrex::Error("Must specify spatial order to be 2,3,4,5 or 6");
2094 }
2095
2096 return nGhostCells;
2097 }
2098
2099 /** \brief Helper function for IO stream */
2101 std::ostream&
2103 {
2104 return *datalog[i];
2105 }
2106
2108 int
2110 {
2111 return datalog.size();
2112 }
2113
2114 /** \brief Variable for CPU timing */
2115 static amrex::Real startCPUTime;
2116 /** \brief Accumulator variable for CPU time used thusfar */
2117 static amrex::Real previousCPUTimeUsed;
2118
2119 /** \brief Get CPU time used */
2120 amrex::Real
2122 {
2123 int numCores = amrex::ParallelDescriptor::NProcs();
2124#ifdef _OPENMP
2126#endif
2127
2128 amrex::Real T =
2129 numCores * (amrex::Real(amrex::ParallelDescriptor::second()) - startCPUTime) +
2131
2132 return T;
2133 }
2134
2135 void setRecordDataInfo (int i, const std::string& filename)
2136 {
2137 if (amrex::ParallelDescriptor::IOProcessor())
2138 {
2139 datalog[i] = std::make_unique<std::fstream>();
2140 datalog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
2141 if (!datalog[i]->good()) {
2142 amrex::FileOpenFailed(filename);
2143 }
2144 }
2145 amrex::ParallelDescriptor::Barrier("REMORA::setRecordDataInfo");
2146 }
2147
2148 amrex::Vector<std::unique_ptr<std::fstream> > datalog;
2149 amrex::Vector<std::string> datalogname;
2150
2151 /** \brief The filename of the ith datalog file. */
2152 const std::string DataLogName (int i) const noexcept { return datalogname[i]; }
2153
2154public:
2155 /** \brief Write job info to stdout */
2156 void writeJobInfo (const std::string& dir) const;
2157 /** \brief Write build info to os */
2158 static void writeBuildInfo (std::ostream& os);
2159
2160 static void print_banner(MPI_Comm /*comm*/, std::ostream& /*out*/);
2161 static void print_usage(MPI_Comm /*comm*/, std::ostream& /*out*/);
2162 static void print_error(MPI_Comm /*comm*/, const std::string& msg);
2163 static void print_summary(std::ostream&);
2164 static void print_tpls(std::ostream& /*out*/);
2165
2166 /** \brief Accessor method for t_old to expose to outside classes */
2167 amrex::Real get_t_old(int lev) const;
2168
2169 /** \brief Time on the model clock, in seconds, of an elapsed time such as t_new */
2170 double model_time (amrex::Real elapsed) const noexcept
2171 {
2172 return start_time + static_cast<double>(elapsed);
2173 }
2174
2175 /** \brief Elapsed time since start_time of a time on the model clock */
2176 amrex::Real elapsed_time (double time) const noexcept
2177 {
2178 return static_cast<amrex::Real>(time - start_time);
2179 }
2180
2181 /** \brief First cons component of the biology block. Problem setups need this to
2182 * write biology initial conditions, since the passive scalars sit between
2183 * salinity and the biology tracers. */
2185 /** \brief Number of biology tracers carried in the state */
2186 int num_bio () const noexcept { return nbio; }
2187 /** \brief Number of passive (dye) scalars carried in the state */
2189
2190 /** \brief Evaluate stability function psi for wind speed */
2192 static amrex::Real bulk_psiu(amrex::Real ZoL) {
2193 // Compute stability function, psi
2194 using namespace amrex;
2195
2196 Real psiu;
2197 if (ZoL < zero) {
2198 // Unstable conditions.
2199 Real x = std::pow(one-Real(15.0)*ZoL,fourth);
2200 Real psik = two*std::log(Real(0.5)*(one+x))+
2201 std::log(Real(0.5)*(one+x*x))-
2202 two*std::atan(x)+Real(0.5)*PI;
2203 // For very unstable conditions, use free-convection (Fairall).
2204 Real sqrt3 = std::sqrt(three);
2205 Real y = std::pow(one-Real(10.15)*ZoL,third);
2206 Real psic = Real(1.5)*std::log(one/Real(three)*(one+y+y*y))-
2207 sqrt3*std::atan((one+two*y)/sqrt3)+PI/sqrt3;
2208 // Match Kansas and free-convection forms with weighting Fw.
2209 Real Zol2 = ZoL*ZoL;
2210 Real Fw = Zol2/(one+Zol2);
2211
2212 psiu = (one-Fw)*psik+Fw*psic;
2213 } else {
2214 // Stable conditions
2215 Real cff=std::min(Real(50.0),Real(0.35)*ZoL);
2216 psiu = -((one+ZoL)+Real(0.6667)*(ZoL-Real(14.28))/
2217 std::exp(cff)+Real(8.525));
2218 }
2219 return psiu;
2220 }
2221
2222 /** \brief Evaluate stability function psi for moisture and heat */
2224 static amrex::Real bulk_psit(amrex::Real ZoL) {
2225 // Compute stability function, psi
2226 using namespace amrex;
2227
2228 Real psit;
2229 if (ZoL < zero) {
2230 // Unstable conditions.
2231 Real x = std::pow(one-Real(15.0)*ZoL,Real(0.5));
2232 Real psik = two*std::log(Real(0.5)*(one+x));
2233 // For very unstable conditions, use free-convection (Fairall).
2234 Real sqrt3=std::sqrt(three);
2235 Real y=std::pow(one-Real(34.15)*ZoL,one/three);
2236 Real psic=Real(1.5)*std::log(one/three*(one+y+y*y))-
2237 sqrt3*std::atan((one+two*y)/sqrt3)+PI/sqrt3;
2238
2239 // Match Kansas and free-convection forms with weighting Fw.
2240 Real ZoL2=ZoL*ZoL;
2241 Real Fw=ZoL2/(one+ZoL2);
2242 psit = (one-Fw)*psik+Fw*psic;
2243 } else {
2244 // Stable conditions.
2245 Real cff=std::min(Real(50.0),Real(0.35)*ZoL);
2246 psit=-(std::pow(one+two*ZoL,Real(1.5))+
2247 Real(0.6667)*(ZoL-Real(14.28))/std::exp(cff)+Real(8.525));
2248 }
2249 return psit;
2250 }
2251};
2252
2253#endif
constexpr amrex::Real three
constexpr amrex::Real two
constexpr amrex::Real one
constexpr amrex::Real fourth
constexpr amrex::Real zero
constexpr amrex::Real PI
constexpr amrex::Real third
PlotfileType
plotfile format
#define Tracer_comp
mf_h setVal(geomdata.ProbHi(2))
A class to hold and interpolate time series data read from a NetCDF file.
A class to hold and interpolate time series data read from a NetCDF file.
Class that stores all relevant simulation state data with methods for time stepping.
Definition REMORA.H:93
static PlotfileType plotfile_type
Native or NetCDF plotfile output.
Definition REMORA.H:2002
std::string nc_grid_file_hires
Grid file for high resolution bathymetry.
Definition REMORA.H:2014
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr_full_domain
Land/sea mask at cell centers on the whole domain at each potential level. Specified at hires_grid_le...
Definition REMORA.H:421
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_EminusP
evaporation minus precipitation [kg/m^2/s], defined at rho-points
Definition REMORA.H:521
ProbCoords prob_coords(int lev) const
Coordinate arrays of level lev, for the prob functions.
amrex::Vector< std::string > nc_riv_file
NetCDF river file(s)
Definition REMORA.H:2031
void set_grid_vars_averaged_down(int lev)
Set pm/pn by averaging down from higher-resolution grid.
Definition REMORA.cpp:827
std::string riv_time_varname
Name of time field for river time.
Definition REMORA.H:2055
int foextrap_periodic_bc() const noexcept
Definition REMORA.H:1455
static void GotoNextLine(std::istream &is)
utility to skip to next line in Header
void ConfigureDriverAtmosToOceanCoupling(bool use_coupling_driver, bool use_two_way_coupling, DriverAtmosForcingMode active_mode)
int nfast
Number of fast steps to take.
Definition REMORA.H:1828
amrex::Vector< std::string > nc_clim_his_file
NetCDF climatology history file(s)
Definition REMORA.H:2034
int ncons
Number of conserved scalars in the state (temperature + salt + passive scalars + biology tracers)
Definition REMORA.H:1797
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr_crse_on_fine
the level's rho-, u- and v-masks copied onto the layout of the level above it coarsened,...
Definition REMORA.H:598
double stop_time
Whether max_step was set in the inputs; the default above is not a distinguishable sentinel.
Definition REMORA.H:1774
void WriteNCMultiFab(const amrex::FabArray< amrex::FArrayBox > &fab, const std::string &name, bool set_ghost=false) const
Write MultiFab in NetCDF format.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta_full_domain
high resolution initial free surface height (2D)
Definition REMORA.H:581
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv2d
v velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:436
std::string nc_init_file_hires
Init file for high resolution.
Definition REMORA.H:2021
void prsgrd(const amrex::Box &bx, const amrex::Box &gbx, const amrex::Box &utbx, const amrex::Box &vtbx, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &rho, const amrex::Array4< amrex::Real > &FC, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const int nrhs, const int N)
Calculate pressure gradient.
int biology_debug_i
Target column i index for biology_debug = 1.
Definition REMORA.H:1814
static amrex::Real fixed_dt
User specified fixed baroclinic time step.
Definition REMORA.H:1824
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_evap
evaporation rate [kg/m^2/s]
Definition REMORA.H:517
amrex::Real last_plot_file_time
Simulation time when we last output a plotfile.
Definition REMORA.H:1757
void update_massflux_3d(int lev, const amrex::Box &bx, const int ioff, const int joff, const amrex::Array4< amrex::Real > &phi, const amrex::Array4< amrex::Real > &phibar, const amrex::Array4< amrex::Real > &Hphi, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pm_or_pn, const amrex::Array4< amrex::Real const > &Dphi1, const amrex::Array4< amrex::Real const > &Dphi2, const amrex::Array4< amrex::Real > &DC, const amrex::Array4< amrex::Real > &FC, const amrex::Array4< amrex::Real const > &msk, const int nnew)
Correct mass flux.
int zvel_bc() const noexcept
Definition REMORA.H:1450
static bool plot_staggered_vels
Whether to write the staggered velocities (not averaged to cell centers)
Definition REMORA.H:1996
void init_bathymetry_from_netcdf(int lev)
Bathymetry data initialization from NetCDF file.
void init_bcs()
Read in boundary parameters from input file and set up data structures.
int xvel_bc() const noexcept
Definition REMORA.H:1448
amrex::Vector< amrex::BCRec > domain_bcs_type
vector (over BCVars) of BCRecs
Definition REMORA.H:1728
bool set_bcs_by_var
whether to set boundary conditions by variable rather than just by side
Definition REMORA.H:1707
void set_zeta_averaged_down(int lev)
Copy over zeta data that has been averaged down from high res.
Definition REMORA.cpp:845
void calculate_nodal_masks(int lev)
Calculate u-, v-, and psi-point masks based on rho-point masks after analytic initialization.
amrex::Long m_warned_surface_temp_nan
Definition REMORA.H:257
std::unique_ptr< NCTimeSeries > qair_data_from_file
Data container for specific humidity read from file.
Definition REMORA.H:1588
static amrex::Real previousCPUTimeUsed
Accumulator variable for CPU time used thusfar.
Definition REMORA.H:2117
amrex::Vector< std::string > cons_names
Names of scalars for plotfile output.
Definition REMORA.H:1941
bool running_with_coupling_driver
True once REMORA has received forcing through the coupling driver.
Definition REMORA.H:526
amrex::Vector< std::unique_ptr< amrex::YAFluxRegister > > advflux_reg
array of flux registers for refluxing in multilevel
Definition REMORA.H:1713
std::unique_ptr< NCTimeSeries > sustr_data_from_file
Data container for u-component surface momentum flux read from file.
Definition REMORA.H:1578
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_fcor
coriolis factor (2D)
Definition REMORA.H:612
int cf_print_iface
print the imposed coarse-fine interface velocity at this baroclinic step (-1 = off)....
Definition REMORA.H:1900
void allocate_init_full_domain()
Allocate multifabs for storing full-domain high resolution initial data.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_btflux
Bottom tracer flux; input arrays.
Definition REMORA.H:512
void init_gls_vmix(int lev, SolverChoice solver_choice)
Initialize GLS variables.
bool time_interp_flux
interpolate the parent's barotropic mass flux in time at the coarse-fine interface,...
Definition REMORA.H:1836
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rubar
barotropic x velocity for the RHS (2D)
Definition REMORA.H:568
void init_biology_from_netcdf(int lev)
Biology initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xvel_full_domain
multilevel data container for high res initial x velocities (u in ROMS)
Definition REMORA.H:404
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h
multilevel data container for current step's z velocities (largely unused; W stored separately)
Definition REMORA.H:413
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm
horizontal scaling factor: 1 / dx (2D)
Definition REMORA.H:603
amrex::MultiFab fine_mask
Mask that zeroes out values on a coarse level underlying grids on the next finest level.
Definition REMORA.H:2069
void set2DPlotVariables(const std::string &pp_plot_var_names_2d)
void FillCoarsePatchMap(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab(), amrex::Interpolater *mapper=nullptr)
fill an entire multifab by interpolating from the coarser level, explicitly specifying interpolator t...
void GetLandSeaMasks(const amrex::MultiFab *&mskr, const amrex::MultiFab *&msku, const amrex::MultiFab *&mskv) const
amrex::Vector< REMORAFillPatcher > FPr_v
Vector over levels of FillPatchers for v (3D)
Definition REMORA.H:1646
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ZoBot
Bottom roughness length [m], defined at rho points.
Definition REMORA.H:537
void init_biology_ic(int lev)
Initialize biology tracers from whichever source remora.biology_ic_type selects. Call after the physi...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg2
correct time average of barotropic x velocity flux for coupling (2D)
Definition REMORA.H:547
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lrflx
longwave radiation
Definition REMORA.H:497
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta_crse_new
see vec_zeta_crse_old (2D)
Definition REMORA.H:566
void init_zeta_full_domain_from_netcdf()
Full-domain high res sea-surface height data initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yv
y_grid on v-points (2D)
Definition REMORA.H:627
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta_crse_old
free surface at the start and end of this level's step, every leapfrog component holding the same val...
Definition REMORA.H:564
static void print_error(MPI_Comm, const std::string &msg)
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive tracer
Definition REMORA.H:393
static bool write_history_file
Whether to output NetCDF files as a single history file with several time steps.
Definition REMORA.H:1575
void init_biology_ic_full_domain()
Full-domain counterpart of init_biology_ic, for the hires_init_level average-down path.
virtual void MakeNewLevelFromCoarse(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Make a new level using provided BoxArray and DistributionMapping and fill with interpolated coarse le...
int tke_bc() const noexcept
Definition REMORA.H:1454
void stretch_transform(int lev)
Calculate vertical stretched coordinates.
std::unique_ptr< NCTimeSeries > rain_data_from_file
Data container for precipitation rate read from file.
Definition REMORA.H:1596
void define_flux_register(int lev)
build or rebuild the flux register between lev and lev-1
Definition REMORA.cpp:2699
void init_masks_full_domain_from_netcdf()
Full domain high-res mask data initialization from NetCDF file.
void set_curvilinear_terms_from_grid_scale(int lev)
Set curvilinear derivative terms on level lev based on pm and pn.
amrex::Gpu::DeviceVector< amrex::Real > s_w
Scaled vertical coordinate (range [0,1]) that transforms to z, defined at w-points (cell faces)
Definition REMORA.H:460
REMORABiology::BiologyModel biology_model
Active biology package.
Definition REMORA.H:1799
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vwind
Wind in the v direction, defined at rho-points.
Definition REMORA.H:486
std::unique_ptr< ProblemBase > prob
Pointer to container of analytical functions for problem definition.
Definition REMORA.H:1679
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
Definition REMORA.H:584
void check_mask_consistency()
Check every level pair's masks against each other, and every level's mask values, reporting according...
Definition REMORA.cpp:1047
void Construct_REMORAFillPatchers(int lev)
Construct FillPatchers.
Definition REMORA.cpp:583
void advance_3d(int lev, amrex::MultiFab &mf_cons, amrex::MultiFab &mf_u, amrex::MultiFab &mf_v, amrex::MultiFab *mf_sstore, amrex::MultiFab *mf_ru, amrex::MultiFab *mf_rv, std::unique_ptr< amrex::MultiFab > &mf_DU_avg1, std::unique_ptr< amrex::MultiFab > &mf_DU_avg2, std::unique_ptr< amrex::MultiFab > &mf_DV_avg1, std::unique_ptr< amrex::MultiFab > &mf_DV_avg2, std::unique_ptr< amrex::MultiFab > &mf_ubar, std::unique_ptr< amrex::MultiFab > &mf_vbar, std::unique_ptr< amrex::MultiFab > &mf_Akv, std::unique_ptr< amrex::MultiFab > &mf_Akt, std::unique_ptr< amrex::MultiFab > &mf_Hz, std::unique_ptr< amrex::MultiFab > &mf_Huon, std::unique_ptr< amrex::MultiFab > &mf_Hvom, std::unique_ptr< amrex::MultiFab > &mf_z_w, amrex::MultiFab const *mf_h, amrex::MultiFab const *mf_pm, amrex::MultiFab const *mf_pn, amrex::MultiFab const *mf_mskr, amrex::MultiFab const *mf_msku, amrex::MultiFab const *mf_mskv, const int N, const amrex::Real dt_lev)
Advance the 3D variables.
void init_grid_vars_from_netcdf(int lev)
Grid variable initialization from NetCDF file.
static int sum_interval
Diagnostic sum output interval in number of steps.
Definition REMORA.H:1988
int history_count
Counter for which time index we are writing to in the netcdf history file.
Definition REMORA.H:1934
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rain
precipitation rate [kg/m^2/s]
Definition REMORA.H:515
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_tke
Turbulent kinetic energy.
Definition REMORA.H:667
void rho_eos(const amrex::Box &bx, const amrex::Array4< amrex::Real const > &state, const amrex::Array4< amrex::Real > &rho, const amrex::Array4< amrex::Real > &rhoA, const amrex::Array4< amrex::Real > &rhoS, const amrex::Array4< amrex::Real > &bvf, const amrex::Array4< amrex::Real > &alpha, const amrex::Array4< amrex::Real > &beta, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &h, const amrex::Array4< amrex::Real const > &mskr, const int N)
Wrapper around equation of state calculation.
static void print_summary(std::ostream &)
int do_substep
Whether to substep fine levels in time.
Definition REMORA.H:1831
amrex::Real m_warned_surface_temp_min
Definition REMORA.H:255
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_stflx
Surface tracer flux; working arrays.
Definition REMORA.H:506
void Evolve()
Advance solution to final time.
Definition REMORA.cpp:273
void t3dmix2(const amrex::Box &bx, const amrex::Array4< amrex::Real > &state, const amrex::Array4< amrex::Real > &state_rhs, const amrex::Array4< amrex::Real const > &diff2, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const amrex::Real dt_lev, const int ncomp, const int N)
Wrapper for harmonic diffusivity for tracers.
void update_nodal_masks(int lev)
Rebuild the u-, v- and psi-point masks from vec_mskr and fill their ghosts.
std::string bdry_time_varname
Default name of time field for boundary data.
Definition REMORA.H:2039
amrex::Real plotfile_fill_value
fill value for masked arrays in amrex plotfiles
Definition REMORA.H:1955
int num_passive_scalars() const noexcept
Number of passive (dye) scalars in the state, not counting biology tracers.
Definition REMORA.H:1476
void ReadCheckpointFile()
read checkpoint file from disk
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_gls
Turbulent generic length scale.
Definition REMORA.H:669
void GetAtmosToOceanPsiLonLat(const amrex::MultiFab *&lon_psi, const amrex::MultiFab *&lat_psi) const
int biology_debug
Biology diagnostic verbosity: 0 off, 1 target column, 2 all columns. See Source/Biology/Fortran/tag_m...
Definition REMORA.H:1812
bool chunk_history_file
Whether to split the netcdf history file into fixed-length chunks.
Definition REMORA.H:1930
void writeJobInfo(const std::string &dir) const
Write job info to stdout.
int num_bc_vars() const noexcept
Definition REMORA.H:1459
void ApplyAtmosphericFluxes(const amrex::Vector< amrex::MultiFab * > &states, amrex::Real time)
Receives atmospheric flux lanes from the driver and assembles REMORA flux inputs.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sustr
Surface stress in the u direction.
Definition REMORA.H:479
amrex::Real get_t_old(int lev) const
Accessor method for t_old to expose to outside classes.
Definition REMORA.cpp:3288
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yp
y_grid on psi-points (2D)
Definition REMORA.H:632
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xr
x_grid on rho points (2D)
Definition REMORA.H:615
void rhs_t_3d(int lev, const amrex::Box &bx, const amrex::Array4< amrex::Real > &t, const amrex::Array4< amrex::Real const > &tempstore, const amrex::Array4< amrex::Real const > &Huon, const amrex::Array4< amrex::Real const > &Hvom, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &W, const amrex::Array4< amrex::Real > &FC, const amrex::Array4< amrex::Real const > &mskr, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const amrex::Array4< int const > &river_pos, const amrex::Array4< amrex::Real const > &river_source, int nrhs, int nnew, int N, const amrex::Real dt_lev, const amrex::Array4< amrex::Real > &fx_reg=amrex::Array4< amrex::Real >(), const amrex::Array4< amrex::Real > &fy_reg=amrex::Array4< amrex::Real >())
RHS terms for tracer.
int yvel_bc() const noexcept
Definition REMORA.H:1449
void build_covered_mask(int crse_lev, amrex::MultiFab &covered)
Average one field down a level, weighted by the land/sea mask.
Definition REMORA.cpp:2986
std::unique_ptr< NCTimeSeries > longwave_down_data_from_file
Data container for downward longwave radiation flux read from file.
Definition REMORA.H:1594
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dvbar_new
see vec_Dvbar_old (2D)
Definition REMORA.H:560
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru2d
u velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:434
virtual void ClearLevel(int lev) override
Delete level data Overrides the pure virtual function in AmrCore.
void init_biology_full_domain_from_netcdf()
Full-domain high-res biology initialization from NetCDF file.
amrex::Vector< std::string > datalogname
Definition REMORA.H:2149
void GetAtmosToOceanVFaceLayout(amrex::BoxArray &ba, amrex::DistributionMapping &dm) const
amrex::Vector< amrex::MultiFab * > zvel_new
multilevel data container for current step's z velocities (largely unused; W stored separately)
Definition REMORA.H:399
void reflux_to(int lev)
apply the lev/lev+1 tracer flux correction onto lev
Definition REMORA.cpp:390
void set_surface_state(int lev)
Initialize or calculate wind speed and other surface state vars from file or analytic.
Definition REMORA.cpp:1621
void GetAtmosToOceanRhoLayout(amrex::BoxArray &ba, amrex::DistributionMapping &dm) const
void check_cf_metrics(int crse_lev)
check that fine cell edges sum to the coarse edge across an interface
Definition REMORA.cpp:2614
int num_scalar() const noexcept
Number of passive (dye) scalars carried in the state.
Definition REMORA.H:2188
AMREX_FORCE_INLINE int ComputeGhostCells(const int &spatial_order)
Helper function to determine number of ghost cells.
Definition REMORA.H:2074
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sstore
additional scratch space for calculations on temp, salt, etc
Definition REMORA.H:647
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xv
x_grid on v-points (2D)
Definition REMORA.H:625
void WriteAtIntermediateTime(int step, amrex::Real cur_time)
Write checkpoint and plotfiles at intermediate point of simulation, if needed.
Definition REMORA.cpp:360
double start_time
Time of the start of the simulation, in seconds on the model clock.
Definition REMORA.H:1780
void init_only(int lev, amrex::Real time)
Init (NOT restart or regrid)
Definition REMORA.cpp:1751
void init_set_vmix(int lev)
Initialize vertical mixing coefficients from file or analytic.
Definition REMORA.cpp:902
void set_2d_cf_bcs(int lev, amrex::Real time, int know, int knew)
set this level's barotropic contact points from its parent, mass-conservingly
void fill_from_bdyfiles(int lev, amrex::MultiFab &mf_to_fill, const amrex::MultiFab &mf_mask, const amrex::Real time, const int bccomp, const int bdy_var_type, const int icomp_to_fill, const int icomp_calc=0, const amrex::MultiFab &mf_calc=amrex::MultiFab(), const amrex::Real=zero)
Fill boundary data from netcdf file.
amrex::Real EvolveOneStep(amrex::Real time, amrex::Real dt_request)
std::unique_ptr< NCTimeSeries > v_clim_data_from_file
Data container for v-velocity climatology data read from file.
Definition REMORA.H:1609
std::string clim_u_time_varname
Name of time field for u climatology data.
Definition REMORA.H:2048
void rhs_uv_3d(int lev, const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real > &rufrc, const amrex::Array4< amrex::Real > &rvfrc, const amrex::Array4< amrex::Real const > &sustr, const amrex::Array4< amrex::Real const > &svstr, const amrex::Array4< amrex::Real const > &bustr, const amrex::Array4< amrex::Real const > &bvstr, const amrex::Array4< amrex::Real const > &Huon, const amrex::Array4< amrex::Real const > &Hvom, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &W, const amrex::Array4< amrex::Real > &FC, int nrhs, int N)
RHS terms for 3D momentum.
void set_grid_scale(int lev)
Set pm and pn arrays and x/y coords on level lev.
void set_coriolis(int lev)
Initialize Coriolis factor from file or analytic.
Definition REMORA.cpp:873
int foextrap_bc() const noexcept
Definition REMORA.H:1456
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Lscale
Vertical mixing turbulent length scale.
Definition REMORA.H:671
DriverAtmosForcingMode
Definition REMORA.H:95
amrex::Vector< REMORAFillPatcher > FPr_u
Vector over levels of FillPatchers for u (3D)
Definition REMORA.H:1644
static amrex::Box clim_nudg_momentum_box(const amrex::Box &nodal_bx, int dir, const amrex::Box &domain, bool is_periodic)
Shrink an x- or y-nodal momentum tilebox to the faces ROMS nudges.
void set_masks_averaged_down(int lev)
Copy this level's land-sea mask out of the full-domain mask that was coarsened down from hires_grid_l...
Definition REMORA.cpp:993
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
Definition REMORA.H:1686
void prestep_diffusion(const amrex::Box &bx, const amrex::Box &gbx, const int ioff, const int joff, const amrex::Array4< amrex::Real > &vel, const amrex::Array4< amrex::Real const > &vel_old, const amrex::Array4< amrex::Real > &rvel, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &Akv, const amrex::Array4< amrex::Real > &FC, const amrex::Array4< amrex::Real const > &sstr, const amrex::Array4< amrex::Real const > &bstr, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const int iic, const int ntfirst, const int nnew, int nstp, int nrhs, int N, const amrex::Real lambda, const amrex::Real dt_lev)
Update velocities or tracers with diffusion/viscosity as the last part of the prestep.
void vert_mean_3d(const amrex::Box &bx, const int ioff, const int joff, const amrex::Array4< amrex::Real > &phi, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &Dphi_avg1, const amrex::Array4< amrex::Real > &DC, const amrex::Array4< amrex::Real > &CF, const amrex::Array4< amrex::Real const > &pm_or_pn, const amrex::Array4< amrex::Real const > &msk, const int nnew, const int N)
Adjust 3D momentum variables based on vertical mean momentum.
amrex::DistributionMapping dm_full_domain
the DistributionMapping every full-domain multifab is built on. Each of those covers the domain in a ...
Definition REMORA.H:1413
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Hz
Width of cells in the vertical (z-) direction (3D, Hz in ROMS)
Definition REMORA.H:424
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akt
Vertical diffusion coefficient (3D)
Definition REMORA.H:444
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku
land/sea mask at x-faces (2D)
Definition REMORA.H:586
std::unique_ptr< NCTimeSeriesRiver > river_source_transportbar
Data container for vertically integrated momentum transport in rivers.
Definition REMORA.H:1620
std::array< bool, AtmosState::NumTypes > driver_atmos_state_from_driver
provenance flags for driver-supplied atmospheric forcing lanes
Definition REMORA.H:524
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rvfrc
v velocity RHS, integrated, including advection and bottom/surface stresses (2D)
Definition REMORA.H:440
int v2d_simple_bc() const noexcept
Definition REMORA.H:1458
void extrapolate_metric_to_physical_boundaries(amrex::MultiFab &mf, const amrex::Geometry &geom)
Extrapolate grid metrics to edge of MultiFab.
void GetAtmosToOceanPsiCoordinates(const amrex::MultiFab *&x_psi, const amrex::MultiFab *&y_psi) const
std::string clim_ubar_time_varname
Name of time field for ubar climatology data.
Definition REMORA.H:2044
std::unique_ptr< NCTimeSeries > u_clim_data_from_file
Data container for u-velocity climatology data read from file.
Definition REMORA.H:1607
std::string check_file
Checkpoint file prefix.
Definition REMORA.H:1923
static amrex::Real startCPUTime
Variable for CPU timing.
Definition REMORA.H:2115
int cf_flux_pc
distribute the parent's interface mass flux piecewise-constantly over the fine faces under each paren...
Definition REMORA.H:1887
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm_full_domain
horizontal scaling factor: 1 / dx (2D) on whole domain
Definition REMORA.H:607
amrex::Vector< amrex::MultiFab * > xvel_old
multilevel data container for last step's x velocities (u in ROMS)
Definition REMORA.H:386
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dubar_old
DU_avg2 per unit cell edge length, at the start and end of this level's step. What a subcycled finer ...
Definition REMORA.H:554
void register_coarse_data(int lev, amrex::Real time, amrex::Real dt_lev)
register this level's completed step as the coarse bracket the next finer level interpolates within
void init_scalars_full_domain_from_netcdf()
Full-domain high-res passive (dye) scalar initialization from NetCDF file.
int cf_avgdown_perimeter
exclude the coarse-fine perimeter's normal-velocity faces from the fine-to-coarse average,...
Definition REMORA.H:1851
void ensure_full_domain_masks(int top_lev)
Make sure the full-domain rho-mask exists on levels 0 through top_lev.
Definition REMORA.cpp:3141
void init_data_from_netcdf(int lev)
Problem initialization from NetCDF file.
void init_masks_from_netcdf(int lev)
Mask data initialization from NetCDF file.
amrex::Vector< amrex::MultiFab * > yvel_new
multilevel data container for current step's y velocities (v in ROMS)
Definition REMORA.H:397
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_uwind
Wind in the u direction, defined at rho-points.
Definition REMORA.H:484
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rufrc
u velocity RHS, integrated, including advection and bottom/surface stresses (2D)
Definition REMORA.H:438
void refine_masks_with_grow_cells(int fine_lev)
Inject the full-domain rho-mask from fine_lev-1 onto fine_lev, piecewise constant,...
Definition REMORA.cpp:3115
static bool plot_nodal_data
Whether to write nodal data (Nu_nd) to plotfiles.
Definition REMORA.H:1999
int regrid_int
how often each level regrids the higher levels of refinement (after a level advances that many time s...
Definition REMORA.H:1913
amrex::Real check_int_time
Checkpoint output interval in seconds.
Definition REMORA.H:1927
amrex::Box nc_hires_init_box
Box for the full domain at nc_hires_init_level.
Definition REMORA.H:2023
DriverAtmosForcingMode driver_atmos_forcing_mode
Active atmosphere-to-ocean forcing contract on the most recent driver apply.
Definition REMORA.H:530
void gls_prestep(int lev, amrex::MultiFab *mf_gls, amrex::MultiFab *mf_tke, amrex::MultiFab &mf_W, amrex::MultiFab *mf_msku, amrex::MultiFab *mf_mskv, const int nstp, const int nnew, const int iic, const int ntfirst, const int N, const amrex::Real dt_lev)
Prestep for GLS calculation.
void init_scalar_metadata()
Build runtime scalar names after nscalar is known.
Definition REMORA.cpp:246
int zeta_bc() const noexcept
Definition REMORA.H:1453
amrex::Vector< amrex::GpuArray< REMORA_BC, AMREX_SPACEDIM *2 > > phys_bc_type
Array holding the "physical" boundary condition types (e.g. "inflow")
Definition REMORA.H:1739
amrex::Vector< amrex::Real > vec_weight2
Weights for calculating avg2 in 2D advance.
Definition REMORA.H:663
amrex::Vector< int > bdy_index
Container to connect boundary data being read in boundary condition containers.
Definition REMORA.H:1752
amrex::Gpu::DeviceVector< amrex::Real > s_r
Scaled vertical coordinate (range [0,1]) that transforms to z, defined at rho points (cell centers)
Definition REMORA.H:458
void Define_REMORAFillPatchers(int lev)
Define FillPatchers.
Definition REMORA.cpp:639
int num_bdy_vars() const noexcept
Definition REMORA.H:1467
amrex::Vector< amrex::IntVect > cum_ref_ratios
Cumulative refinement ratio between level 0 and level i.
Definition REMORA.H:2026
const amrex::Vector< std::string > derived_names_3d
Names of derived fields for 3d plotfile fields.
Definition REMORA.H:1944
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_shflx
sensible heat flux
Definition REMORA.H:503
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_visc2_p
Harmonic viscosity defined on the psi points (corners of horizontal grid cells)
Definition REMORA.H:446
void set_drag(int lev)
Initialize or calculate bottom drag.
amrex::MultiFab & build_fine_mask(int lev)
Make mask to zero out covered cells (for mesh refinement)
amrex::Real plot_int_time
Plotfile output interval in seconds.
Definition REMORA.H:1921
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_dmde
d(1/m)/d(eta)
Definition REMORA.H:644
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rvbar
barotropic y velocity for the RHS (2D)
Definition REMORA.H:570
amrex::Vector< int > num_files_at_level
how many netcdf input files specified at each level
Definition REMORA.H:1684
void advance_2d_onestep(int lev, amrex::Real dt_lev, amrex::Real dtfast_lev, int my_iif, int nfast_counter)
2D advance, one predictor/corrector step
amrex::Vector< REMORAFillPatcher > FPr_vbar
Vector over levels of FillPatchers for vbar (2D)
Definition REMORA.H:1654
void AverageDownTo(int crse_lev)
more flexible version of AverageDown() that lets you average down across multiple levels
Definition REMORA.cpp:2840
int steps_per_history_file
Time steps per netcdf history file. Must be > 0 if chunk_history_file.
Definition REMORA.H:1932
void post_timestep(int nstep, amrex::Real time, amrex::Real dt_lev)
Called after every level 0 timestep.
Definition REMORA.cpp:440
int max_step
maximum number of steps
Definition REMORA.H:1770
void stretch_transform_full_domain(int lev, const amrex::MultiFab &mf_h, const amrex::MultiFab &mf_zeta, amrex::MultiFab &mf_z_r, amrex::MultiFab &mf_z_w)
Calculate z_r and z_w on full-domain arrays at a level not yet created.
amrex::Vector< amrex::MultiFab * > zvel_old
multilevel data container for last step's z velocities (largely unused; W stored separately)
Definition REMORA.H:390
std::unique_ptr< NCTimeSeries > svstr_data_from_file
Data container for v-component surface momentum flux read from file.
Definition REMORA.H:1580
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_r
z coordinates at rho points (cell centers)
Definition REMORA.H:453
void coarsen_bathymetry_with_grow_cells(int crse_lev)
Coarsen the full-domain bathymetry from crse_lev+1 onto crse_lev, grow cells included,...
Definition REMORA.cpp:1272
amrex::Vector< std::string > nc_frc_file
NetCDF forcing file(s)
Definition REMORA.H:2029
amrex::Vector< int > num_boxes_at_level
how many boxes specified at each level by tagging criteria
Definition REMORA.H:1682
amrex::Vector< amrex::MultiFab * > xvel_new
multilevel data container for current step's x velocities (u in ROMS)
Definition REMORA.H:395
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lhflx
latent heat flux
Definition REMORA.H:501
void refinement_criteria_setup()
Set refinement criteria.
int u2d_simple_bc() const noexcept
Definition REMORA.H:1457
void init_scalars_from_netcdf(int lev)
Passive (dye) scalar initialization from NetCDF file. Called from init_data_from_netcdf: dye follows ...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskp
land/sea mask at cell corners (2D)
Definition REMORA.H:590
void remora_advance(int level, amrex::MultiFab &cons_old, amrex::MultiFab &cons_new, amrex::MultiFab &xvel_old, amrex::MultiFab &yvel_old, amrex::MultiFab &zvel_old, amrex::MultiFab &xvel_new, amrex::MultiFab &yvel_new, amrex::MultiFab &zvel_new, amrex::MultiFab &source, const amrex::Geometry fine_geom, const amrex::Real dt, const amrex::Real time)
Interface for advancing the data at one level by one "slow" timestep.
int Bio_comp
First cons component of the biology block, i.e. Tracer_comp + nscalar. The state is laid out as temp,...
Definition REMORA.H:1794
int last_check_file_step
Step when we last output a checkpoint file.
Definition REMORA.H:1760
int bdy_zeta() const noexcept
Definition REMORA.H:1466
void prestep(int lev, amrex::MultiFab &mf_uold, amrex::MultiFab &mf_vold, amrex::MultiFab &mf_u, amrex::MultiFab &mf_v, amrex::MultiFab *mf_ru, amrex::MultiFab *mf_rv, amrex::MultiFab &S_old, amrex::MultiFab &S_new, amrex::MultiFab &mf_W, amrex::MultiFab &mf_DC, const amrex::MultiFab *mf_z_r, const amrex::MultiFab *mf_z_w, const amrex::MultiFab *mf_h, const amrex::MultiFab *mf_pm, const amrex::MultiFab *mf_pn, const amrex::MultiFab *mf_sustr, const amrex::MultiFab *mf_svstr, const amrex::MultiFab *mf_bustr, const amrex::MultiFab *mf_bvstr, const amrex::MultiFab *mf_msku, const amrex::MultiFab *mf_mskv, const int iic, const int nfirst, const int nnew, int nstp, int nrhs, int N, const amrex::Real dt_lev)
Wrapper function for prestep.
void init_beta_plane_coriolis(int lev)
Calculate Coriolis parameters from beta plane parametrization.
std::string clim_vbar_time_varname
Name of time field for vbar climatology data.
Definition REMORA.H:2046
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bvf
Brunt-Vaisala frequency (3D)
Definition REMORA.H:654
virtual void RemakeLevel(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Remake an existing level using provided BoxArray and DistributionMapping and fill with existing fine ...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lonp
longitude on psi-points (2D, degrees east); only filled when the grid NetCDF file carries lon_psi
Definition REMORA.H:636
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv
land/sea mask at y-faces (2D)
Definition REMORA.H:588
void init_masks(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Allocate MultiFabs for masks.
amrex::Vector< int > nsubsteps
How many substeps on each level?
Definition REMORA.H:1691
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
Definition REMORA.H:1710
void ComputeDt()
a wrapper for estTimeStep()
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku_crse_on_fine
Definition REMORA.H:599
void fill_3d_masks(int lev)
Copy maskr to all z levels.
static void writeBuildInfo(std::ostream &os)
Write build info to os.
std::unique_ptr< NCTimeSeries > EminusP_data_from_file
Data container for evaporation minus precipitation read from file.
Definition REMORA.H:1600
void FillCoarsePatch(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level
virtual void ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real time, int ngrow) override
Tag cells for refinement.
int plot_int
Plotfile output interval in iterations.
Definition REMORA.H:1919
std::unique_ptr< NCTimeSeries > cloud_data_from_file
Data container for cloud cover fraction read from file.
Definition REMORA.H:1598
amrex::Real getCPUTime() const
Get CPU time used.
Definition REMORA.H:2121
void WriteNCPlotFile(int istep, amrex::MultiFab const *plotMF, int lev=0)
Write plotfile using NetCDF (wrapper)
amrex::YAFluxRegister * getAdvFluxReg(int lev)
flux register between lev and lev-1
Definition REMORA.H:1716
int nbio
Number of biology tracers, set by the active biology model. Zero when no biology model is active.
Definition REMORA.H:1791
void WriteAtFinalTime()
Write checkpoint and plotfiles at end of simulation.
Definition REMORA.cpp:345
void InitData()
Initialize multilevel data.
Definition REMORA.cpp:465
void update_avgdown_masks(int crse_lev)
Make sure the coarse masks the average-down kernels read sit on the coarsened layout of level crse_le...
Definition REMORA.cpp:2766
void set3DPlotVariables(const std::string &pp_plot_var_names_3d)
amrex::Vector< int > istep
which step?
Definition REMORA.H:1689
void uv3dmix(const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real > &u, const amrex::Array4< amrex::Real > &v, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &rufrc, const amrex::Array4< amrex::Real > &rvfrc, const amrex::Array4< amrex::Real const > &visc2_p, const amrex::Array4< amrex::Real const > &visc2_r, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &mskp, int nrhs, int nnew, const amrex::Real dt_lev)
Harmonic viscosity.
void WriteCheckpointFile()
write checkpoint file to disk
std::string nc_clim_coeff_file
NetCDF climatology coefficient file.
Definition REMORA.H:2036
void lin_eos(const amrex::Box &bx, const amrex::Array4< amrex::Real const > &state, const amrex::Array4< amrex::Real > &rho, const amrex::Array4< amrex::Real > &rhoA, const amrex::Array4< amrex::Real > &rhoS, const amrex::Array4< amrex::Real > &bvf, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &h, const amrex::Array4< amrex::Real const > &mskr, const int N)
Calculate density and related quantities from linear equation of state.
void setRecordDataInfo(int i, const std::string &filename)
Definition REMORA.H:2135
void advance_3d_ml(int lev, amrex::Real dt_lev)
3D advance on a single level
const std::string DataLogName(int i) const noexcept
The filename of the ith datalog file.
Definition REMORA.H:2152
void set_analytic_vmix(int lev)
Set vertical mixing coefficients from analytic.
Definition REMORA.cpp:919
void mask_arrays_for_write(int lev, amrex::Real fill_value, amrex::Real fill_where)
Mask data arrays before writing output.
void coarsen_masks_with_grow_cells(int crse_lev)
Coarsen the full-domain rho-mask from crse_lev+1 onto crse_lev, grow cells included,...
Definition REMORA.cpp:1014
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rhoS
density perturbation
Definition REMORA.H:650
amrex::Vector< std::string > bdry_time_name_byvar
Name of time fields for boundary data.
Definition REMORA.H:2041
void rhs_uv_2d(int lev, const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &Duon, const amrex::Array4< amrex::Real const > &Dvom, const int nrhs)
RHS terms for 2D momentum.
static int file_min_digits
Minimum number of digits in plotfile name or chunked history file.
Definition REMORA.H:1993
void init_riv_pos_from_netcdf(int lev)
static amrex::Vector< std::string > nc_bdry_file
NetCDF boundary data.
Definition REMORA.H:58
amrex::Vector< REMORAFillPatcher > FPr_Dubar
Vector over levels of FillPatchers for Dubar (2D)
Definition REMORA.H:1656
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_visc2_r
Harmonic viscosity defined on the rho points (centers)
Definition REMORA.H:448
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yvel_full_domain
multilevel data container for high res initial y velocities (v in ROMS)
Definition REMORA.H:406
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_svstr
Surface stress in the v direction.
Definition REMORA.H:481
std::unique_ptr< NCTimeSeries > srflx_data_from_file
Data container for shortwave radiation flux read from file.
Definition REMORA.H:1592
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Huon
u-volume flux (3D)
Definition REMORA.H:426
REMORA()
Definition REMORA.cpp:69
void store_2d_flux(int lev)
store this level's barotropic mass flux per unit cell edge length
void FillBdyCCVels(int lev, amrex::MultiFab &mf_cc_vel)
Fill the physical boundary conditions for cell-centered velocity (diagnostic only)
void set_zeta(int lev)
Initialize zeta from file or analytic.
Definition REMORA.cpp:712
static amrex::Real change_max
Fraction maximum change in subsequent time steps.
Definition REMORA.H:1822
void calc_stretch_coeffs()
calculate vertical stretch coefficients
int check_cf_metrics_flag
measure whether fine cell edges tile the coarse ones at a coarse-fine interface, which is what makes ...
Definition REMORA.H:1908
int num_bio() const noexcept
Number of biology tracers carried in the state.
Definition REMORA.H:2186
void init_zeta_from_netcdf(int lev)
Sea-surface height data initialization from NetCDF file.
void set_zeta_average(int lev)
Set Zt_avg1 to zeta.
void init_coriolis_from_netcdf(int lev)
Coriolis parameter data initialization from NetCDF file.
amrex::Vector< REMORAFillPatcher > FPr_Dvbar
Vector over levels of FillPatchers for Dvbar (2D)
Definition REMORA.H:1658
static void print_usage(MPI_Comm, std::ostream &)
std::string pp_prefix
default prefix for input file parameters
Definition REMORA.H:381
void GetDeckConfiguredAtmosStateLanes(std::array< bool, AtmosState::NumTypes > &deck_configured) const
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h_full_domain
Bathymetry data on the whole domain at each potential level.
Definition REMORA.H:416
void set_bathymetry(int lev)
Initialize bathymetry from file or analytic.
Definition REMORA.cpp:751
amrex::Vector< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
Definition REMORA.H:388
std::unique_ptr< NCTimeSeries > ubar_clim_data_from_file
Data container for ubar climatology data read from file.
Definition REMORA.H:1603
void init_stuff(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Allocate MultiFabs for state and evolution variables.
void init_full_domain_from_analytic()
Initialize high-resolution initial data, zeta included, from analytic functions.
TimeInterpolatedData GetDataAtTime(int lev, amrex::Real time)
utility to copy in data from old and/or new state into another multifab
amrex::Real m_warned_surface_temp_max
Definition REMORA.H:256
void Advance(int lev, amrex::Real time, amrex::Real dt_lev, int iteration, int ncycle)
advance a single level for a single time step
void init_data_full_domain_from_netcdf()
High resolution roblem initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rhoA
vertically-averaged density
Definition REMORA.H:652
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg1
time average of barotropic y velocity flux
Definition REMORA.H:549
void init_ref_ratios()
Reject vertical refinement and accumulate the refinement ratios.
Definition REMORA.cpp:217
amrex::Vector< REMORAFillPatcher > FPr_c
Vector over levels of FillPatchers for scalars.
Definition REMORA.H:1642
int hires_init_level
Which level the high resolution initialization data is at.
Definition REMORA.H:2019
amrex::Vector< std::string > clim_cons_time_varname
Vector over cons components of the name of the time field for that tracer's climatology data.
Definition REMORA.H:2053
std::unique_ptr< NCTimeSeries > Tair_data_from_file
Data container for air temperature read from file.
Definition REMORA.H:1586
int bdy_vbar() const noexcept
Definition REMORA.H:1465
int cf_avgdown_bar
Definition REMORA.H:1868
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real bulk_psiu(amrex::Real ZoL)
Evaluate stability function psi for wind speed.
Definition REMORA.H:2192
void apply_clim_nudg(const amrex::Box &bx, int ioff, int joff, const amrex::Array4< amrex::Real > &var, const amrex::Array4< amrex::Real const > &var_old, const amrex::Array4< amrex::Real const > &var_clim, const amrex::Array4< amrex::Real const > &clim_coeff, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Real dt_lev=zero)
Apply climatology nudging.
static void print_banner(MPI_Comm, std::ostream &)
int nscalar
Number of passive (dye) scalars carried in the state, beyond temperature and salinity....
Definition REMORA.H:1788
std::string clim_v_time_varname
Name of time field for v climatology data.
Definition REMORA.H:2050
amrex::Vector< REMORAFillPatcher > FPr_w
Vector over levels of FillPatchers for w.
Definition REMORA.H:1648
amrex::Gpu::DeviceVector< amrex::Real > Cs_r
Stretching coefficients at rho points.
Definition REMORA.H:468
std::unique_ptr< NCTimeSeries > Uwind_data_from_file
Data container for u-direction wind read from file.
Definition REMORA.H:1582
std::unique_ptr< NCTimeSeries > Pair_data_from_file
Data container for air pressure read from file.
Definition REMORA.H:1590
int cf_fill_vel_after
re-fill the child's 3D velocity from the parent after the step, so the coarse-fine boundary carries t...
Definition REMORA.H:1859
amrex::Vector< amrex::Real > t_new
new time at each level, in seconds since start_time
Definition REMORA.H:1700
void SetStartTime(double time) noexcept
Set remora.start_time. Call before InitData, which starts the clock from it.
Definition REMORA.H:125
void init_stretch_coeffs()
initialize and calculate stretch coefficients
void init_bdry_from_netcdf(int lev)
Boundary data initialization from NetCDF file.
void scale_rhs_vars_inv(int lev)
Scale RHS momentum variables by cell area, needed after FillPatch to different levels.
static SolverChoice solverChoice
Container for algorithmic choices.
Definition REMORA.H:1949
void ApplyAtmosphericStates(const amrex::Vector< amrex::MultiFab * > &states, amrex::Real time)
Receives atmospheric states from the driver and applies unit conversions.
void set_grid_coords_from_grid_scale(int lev)
Set x/y coords on level lev based on pm and pn.
void resize_stuff(int lev)
Resize variable containers to accommodate data on levels 0 to max_lev.
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > vec_river_position
iMultiFab for river positions; contents are indices of rivers
Definition REMORA.H:1627
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akk
Turbulent kinetic energy vertical diffusion coefficient.
Definition REMORA.H:673
void set_masks(int lev)
Initialize land-sea masks from file or analytic.
Definition REMORA.cpp:942
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag2
Quadratic drag coefficient [unitless], defined at rho points.
Definition REMORA.H:535
void set_zeta_to_Ztavg(int lev, bool apply_eminusp=true)
Set zeta components to be equal to time-averaged Zt_avg1.
bool m_reported_atm_flux_validation
Latch so the flux validation block prints once per run unless remora.v >= 1.
Definition REMORA.H:252
void SetLongwaveFromDriver()
bool driver_uses_two_way_coupling
Driver-level direction flag copied in before InitData.
Definition REMORA.H:528
amrex::Vector< amrex::Vector< std::unique_ptr< NCTimeSeriesBoundary > > > boundary_series
Vector over BdyVars of boundary series data containers.
Definition REMORA.H:1623
int cf_set_width
Width for fixing values at coarse-fine interface.
Definition REMORA.H:1639
int biology_debug_j
Target column j index for biology_debug = 1.
Definition REMORA.H:1816
void WriteGenericPlotfileHeaderWithBathymetry(std::ostream &HeaderFile, int nlevels, const amrex::Vector< amrex::BoxArray > &bArray, const amrex::Vector< std::string > &varnames_3d, const amrex::Vector< std::string > &varnames_2d_rho, const amrex::Vector< std::string > &varnames_2d_u, const amrex::Vector< std::string > &varnames_2d_v, const amrex::Vector< amrex::Geometry > &my_geom, double time, const amrex::Vector< int > &level_steps, const amrex::Vector< amrex::IntVect > &rr, const std::string &versionName, const std::string &levelPrefix, const std::string &mfPrefix) const
write out header data for an AMReX plotfile
void ReadParameters()
read in some parameters from inputs file
Definition REMORA.cpp:2111
static void print_tpls(std::ostream &)
int do_reflux
correct the coarse tracer with the finer level's accumulated advective flux at their interface....
Definition REMORA.H:1847
void vert_visc_3d(const amrex::Box &bx, const int ioff, const int joff, const amrex::Array4< amrex::Real > &phi, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real > &Hzk, const amrex::Array4< amrex::Real > &AK, const amrex::Array4< amrex::Real const > &Akv, const amrex::Array4< amrex::Real > &BC, const amrex::Array4< amrex::Real > &DC, const amrex::Array4< amrex::Real > &FC, const amrex::Array4< amrex::Real > &CF, const int nnew, const int N, const amrex::Real dt_lev)
Calculate effects of vertical viscosity or diffusivity.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru
u velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:430
void clear_avgdown_masks(int lev)
Drop the cached average-down masks of every level pair that involves lev.
Definition REMORA.cpp:2590
void sum_integrated_quantities(amrex::Real time)
Integrate conserved quantities for diagnostics.
static int total_nc_plot_file_step
Definition REMORA.H:1480
amrex::Vector< amrex::Real > vec_weight1
Weights for calculating avg1 in 2D advance.
Definition REMORA.H:661
int bdy_ubar() const noexcept
Definition REMORA.H:1464
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xp
x_grid on psi-points (2D)
Definition REMORA.H:630
int cf_impose_flux
impose the parent's barotropic mass flux on DUon/DVom at the coarse-fine interface,...
Definition REMORA.H:1842
void advance_biology(int lev, amrex::MultiFab const &mf_cons_old, amrex::MultiFab &mf_cons_new, int N, amrex::Real dt_lev)
Apply biological tracer source/sink terms.
void FillPatchNoBC(int lev, amrex::Real time, amrex::MultiFab &mf_to_be_filled, amrex::Vector< amrex::MultiFab * > const &mfs, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const bool fill_set=false, amrex::Vector< amrex::MultiFab * > const &mfs_crse_old={}, amrex::Vector< amrex::MultiFab * > const &mfs_crse_new={})
Fill a new MultiFab by copying in phi from valid region and filling ghost cells without applying boun...
static amrex::Vector< amrex::Vector< std::string > > nc_grid_file
NetCDF grid file.
Definition REMORA.H:60
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_longwave_down
Downward longwave radiation.
Definition REMORA.H:499
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
Definition REMORA.H:578
int ubar_bc() const noexcept
Definition REMORA.H:1451
amrex::Gpu::DeviceVector< int > river_direction
Vector over rivers of river direction: 0: u-face; 1: v-face; 2: w-face.
Definition REMORA.H:1629
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vbar
barotropic y velocity (2D)
Definition REMORA.H:576
void GetAtmosToOceanUFaceLayout(amrex::BoxArray &ba, amrex::DistributionMapping &dm) const
void ReadNCMultiFab(amrex::FabArray< amrex::FArrayBox > &fab, const std::string &name, int coordinatorProc=amrex::ParallelDescriptor::IOProcessorNumber(), int allow_empty_mf=0)
Read MultiFab in NetCDF format.
amrex::Box nc_hires_grid_box
Box for the full domain at nc_hires_grid_level.
Definition REMORA.H:2016
void FillCoarsePatchPC(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level using the piecewise constant interpol...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg1
time average of barotropic x velocity flux (2D)
Definition REMORA.H:545
amrex::Gpu::DeviceVector< amrex::Real > Cs_w
Stretching coefficients at w points.
Definition REMORA.H:470
bool expand_plotvars_to_unif_rr
whether plotfile variables should be expanded to a uniform refinement ratio
Definition REMORA.H:1952
void advance_2d(int lev, amrex::MultiFab const *mf_rhoS, amrex::MultiFab const *mf_rhoA, amrex::MultiFab *mf_ru2d, amrex::MultiFab *mf_rv2d, amrex::MultiFab *mf_rufrc, amrex::MultiFab *mf_rvfrc, amrex::MultiFab *mf_Zt_avg1, std::unique_ptr< amrex::MultiFab > &mf_DU_avg1, std::unique_ptr< amrex::MultiFab > &mf_DU_avg2, std::unique_ptr< amrex::MultiFab > &mf_DV_avg1, std::unique_ptr< amrex::MultiFab > &mf_DV_avg2, std::unique_ptr< amrex::MultiFab > &mf_rubar, std::unique_ptr< amrex::MultiFab > &mf_rvbar, std::unique_ptr< amrex::MultiFab > &mf_rzeta, std::unique_ptr< amrex::MultiFab > &mf_ubar, std::unique_ptr< amrex::MultiFab > &mf_vbar, amrex::MultiFab *mf_zeta, amrex::MultiFab const *mf_h, amrex::MultiFab const *mf_pm, amrex::MultiFab const *mf_pn, amrex::MultiFab const *mf_fcor, amrex::MultiFab const *mf_visc2_p, amrex::MultiFab const *mf_visc2_r, amrex::MultiFab const *mf_mskr, amrex::MultiFab const *mf_msku, amrex::MultiFab const *mf_mskv, amrex::MultiFab const *mf_mskp, amrex::Real dtfast_lev, bool predictor_2d_step, bool first_2d_step, int my_iif, int &next_indx1)
Perform a 2D predictor (predictor_2d_step=True) or corrector (predictor_2d_step=False) step.
int plot_file_on_restart
Whether to output a plotfile on restart from checkpoint.
Definition REMORA.H:1764
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_alpha
Thermal expansion coefficient (3D)
Definition REMORA.H:656
void set_2darrays(int lev)
Set 2D momentum arrays from 3D momentum.
void SetDriverAtmosToOceanForcingMode(DriverAtmosForcingMode mode)
void init_analytic(int lev)
Initialize initial problem data from analytic functions.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ubar
barotropic x velocity (2D)
Definition REMORA.H:574
void FillPatch(int lev, amrex::Real time, amrex::MultiFab &mf_to_be_filled, amrex::Vector< amrex::MultiFab * > const &mfs, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const bool fill_set=false, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab(), amrex::Vector< amrex::MultiFab * > const &mfs_crse_old={}, amrex::Vector< amrex::MultiFab * > const &mfs_crse_new={})
Fill a new MultiFab by copying in phi from valid region and filling ghost cells.
void restore_perimeter_faces(const amrex::MultiFab &saved, amrex::MultiFab &mf, const amrex::MultiFab &covered, int dir, int ncomp)
put back the coarse normal-velocity faces on the fine patch's perimeter
Definition REMORA.cpp:3021
void InitializeLevelFromData(int lev, const amrex::MultiFab &initial_data)
Initialize the new-time data at a level from the initial_data MultiFab.
amrex::Vector< amrex::MultiFab * > cons_old
multilevel data container for last step's scalar data: temperature, salinity, passive tracer
Definition REMORA.H:384
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bustr
Bottom stress in the u direction.
Definition REMORA.H:540
AMREX_FORCE_INLINE int NumDataLogs() noexcept
Definition REMORA.H:2109
amrex::Real volWgtSumMF(int lev, const amrex::MultiFab &mf, int comp, bool local, bool finemask)
Perform the volume-weighted sum.
std::string frc_time_varname
Name of time field for forcing data.
Definition REMORA.H:2057
void init_clim_nudg_coeff_from_netcdf(int lev)
Climatology nudging coefficient initialization from NetCDF file.
amrex::Vector< REMORAFillPatcher > FPr_ubar
Vector over levels of FillPatchers for ubar (2D)
Definition REMORA.H:1652
bool is_it_time_for_action(int nstep, amrex::Real time, amrex::Real dt, int action_interval, amrex::Real action_per)
Decide if it is time to take an action.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cons_full_domain
multilevel data container for high res initial data: temperature, salinity, passive tracer
Definition REMORA.H:402
int vbar_bc() const noexcept
Definition REMORA.H:1452
std::unique_ptr< NCTimeSeries > Vwind_data_from_file
Data container for v-direction wind read from file.
Definition REMORA.H:1584
static constexpr bool DriverUsesStateForcing(DriverAtmosForcingMode mode) noexcept
Definition REMORA.H:100
static int ndtfast
User specified, number of barotropic steps per baroclinic step.
Definition REMORA.H:1826
std::string PlotFileName(int lev) const
get plotfile name
void init_bathymetry_full_domain_from_netcdf()
Full domain high-res bathymetry data initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg2
correct time average of barotropic y velocity flux for coupling (2D)
Definition REMORA.H:551
amrex::Vector< std::unique_ptr< NCTimeSeries > > cons_clim_data_from_file
Vector over cons components of climatology data read from file.
Definition REMORA.H:1613
void set_hmixcoef(int lev)
Initialize horizontal mixing coefficients.
Definition REMORA.cpp:1317
amrex::Array< std::string, 2 *AMREX_SPACEDIM > domain_bc_type
Array of strings describing domain boundary conditions.
Definition REMORA.H:1733
amrex::Vector< std::unique_ptr< NCTimeSeriesRiver > > river_source_cons
Vector of data containers for scalar data in rivers.
Definition REMORA.H:1616
amrex::Real estTimeStep(int lev) const
compute dt from CFL considerations
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yu
y_grid on u-points (2D)
Definition REMORA.H:622
void WriteNCPlotFile_which(int lev, int which_subdomain, amrex::MultiFab const *plotMF, bool write_header, ncutils::NCFile &ncf, bool is_history)
Write a particular NetCDF plotfile.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_dndx
d(1/n)/d(xi)
Definition REMORA.H:642
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bvstr
Bottom stress in the v direction.
Definition REMORA.H:542
void timeStep(int lev, amrex::Real time, int iteration)
advance a level by dt, includes a recursive call for finer levels
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rzeta
free surface height for the RHS (2D)
Definition REMORA.H:572
std::unique_ptr< NCTimeSeriesRiver > river_source_transport
Data container for momentum transport in rivers.
Definition REMORA.H:1618
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_phys_nd
z coordinates at psi points (cell nodes)
Definition REMORA.H:473
int cf_time_interp_zeta
interpolate the parent in time onto the child's own sub-time, as put_refine2d does,...
Definition REMORA.H:1881
void init_grid_vars_full_domain_from_netcdf()
Full domain high-res grid variable initialization from NetCDF file.
void AverageDown()
set covered coarse cells to be the average of overlying fine cells
Definition REMORA.cpp:2571
amrex::Real netcdf_fill_value
fill value for masked arrays in netcdf output
Definition REMORA.H:1957
void set_nsubsteps(int nlevs_max)
size nsubsteps and set how many steps each level takes per parent step
Definition REMORA.cpp:2724
int bdy_cons(int icomp) const noexcept
Accessors for the ncons-dependent entries of BdyVars.
Definition REMORA.H:1463
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dvbar_old
DV_avg2 per unit cell edge length, see vec_Dubar_old (2D)
Definition REMORA.H:558
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xu
x_grid on u-points (2D)
Definition REMORA.H:620
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn_full_domain
horizontal scaling factor: 1 / dy (2D) on whole domain
Definition REMORA.H:609
void timeStepML(amrex::Real time, int iteration)
advance all levels by dt, loops over finer levels
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > vec_nudg_coeff
Climatology nudging coefficients.
Definition REMORA.H:678
void print_timestep_hierarchy() const
report the per-level slow/fast timestep hierarchy; call after ComputeDt
void set_weights(int lev)
Set weights for averaging 3D variables to 2D.
void prestep_t_advection(int lev, const amrex::Box &tbx, const amrex::Box &gbx, const amrex::Array4< amrex::Real > &tempold, const amrex::Array4< amrex::Real > &tempcache, const amrex::Array4< amrex::Real > &Hz, const amrex::Array4< amrex::Real > &Huon, const amrex::Array4< amrex::Real > &Hvom, const amrex::Array4< amrex::Real > &W, const amrex::Array4< amrex::Real > &DC, const amrex::Array4< amrex::Real > &FC, const amrex::Array4< amrex::Real > &sstore, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &h, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const amrex::Array4< int const > &river_pos, const amrex::Array4< amrex::Real const > &river_source, int iic, int ntfirst, int nrhs, int N, const amrex::Real dt_lev)
Prestep advection calculations for the tracers.
const amrex::DistributionMapping & full_domain_dmap()
The shared full-domain DistributionMapping, built on first use.
int cf_avgdown_stencil
average the fine velocity onto the coarse over ROMS's nine-point stencil (fine2coarse2d,...
Definition REMORA.H:1896
AMREX_FORCE_INLINE std::ostream & DataLog(int i)
Helper function for IO stream.
Definition REMORA.H:2102
int cf_set_2d_bcs
0 = never impose the 2D coarse-fine interface condition, 1 = every fast step, 2 = only the first fast...
Definition REMORA.H:1867
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn
horizontal scaling factor: 1 / dy (2D)
Definition REMORA.H:605
void curvilinear(const amrex::Box &bx, const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &dndx, const amrex::Array4< amrex::Real const > &dmde, int nrhs, int nr)
Calculate curvilinear advection terms.
amrex::Vector< std::unique_ptr< std::fstream > > datalog
Definition REMORA.H:2148
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akv
Vertical viscosity coefficient (3D)
Definition REMORA.H:442
static amrex::Real cfl
CFL condition.
Definition REMORA.H:1820
amrex::Vector< amrex::GpuArray< bool, AMREX_SPACEDIM *2 > > phys_bc_need_data
These are flags that indicate whether we need to read in boundary data from file.
Definition REMORA.H:1746
void init_masks_full_domain_from_analytic()
Full domain land-sea mask initialization from analytic.
void append3DPlotVariables(const std::string &pp_plot_var_names_3d)
REMORABiology::FennelParameters fennel_params
Runtime parameters for the Fennel biology package.
Definition REMORA.H:1801
void allocate_bathymetry_grid_vars_full_domain()
Allocate multifabs for storing full-domain bathymetry and grid vars data.
virtual void MakeNewLevelFromScratch(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Make a new level from scratch using provided BoxArray and DistributionMapping. Only used during initi...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv_crse_on_fine
Definition REMORA.H:600
amrex::Vector< std::string > plot_var_names_3d
Names of 3D variables to output to AMReX plotfile.
Definition REMORA.H:1937
amrex::Real elapsed_time(double time) const noexcept
Elapsed time since start_time of a time on the model clock.
Definition REMORA.H:2176
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_stflux
Surface tracer flux; input arrays.
Definition REMORA.H:508
void set_init_data_averaged_down(int lev)
Problem initialization from averaged-down high resolution data.
Definition REMORA.cpp:856
static int verbose
Verbosity level of output.
Definition REMORA.H:1985
void setup_step(int lev, amrex::Real time, amrex::Real dt_lev)
Set everything up for a step on a level.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dubar_new
see vec_Dubar_old (2D)
Definition REMORA.H:556
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag
Linear drag coefficient [m/s], defined at rho points.
Definition REMORA.H:533
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cloud
cloud cover fraction [0-1], defined at rho-points
Definition REMORA.H:519
void WriteMultiLevelPlotfileWithBathymetry(const std::string &plotfilename, int nlevels, const amrex::Vector< const amrex::MultiFab * > &mf, const amrex::Vector< const amrex::MultiFab * > &mf_nd, const amrex::Vector< const amrex::MultiFab * > &mf_u, const amrex::Vector< const amrex::MultiFab * > &mf_v, const amrex::Vector< const amrex::MultiFab * > &mf_w, const amrex::Vector< const amrex::MultiFab * > &mf_2d_rho, const amrex::Vector< const amrex::MultiFab * > &mf_2d_u, const amrex::Vector< const amrex::MultiFab * > &mf_2d_v, const amrex::Vector< std::string > &varnames_3d, const amrex::Vector< std::string > &varnames_2d_rho, const amrex::Vector< std::string > &varnames_2d_u, const amrex::Vector< std::string > &varnames_2d_v, const amrex::Vector< amrex::Geometry > &my_geom, double time, const amrex::Vector< int > &level_steps, const amrex::Vector< amrex::IntVect > &rr, const std::string &versionName="HyperCLaw-V1.1", const std::string &levelPrefix="Level_", const std::string &mfPrefix="Cell", const amrex::Vector< std::string > &extra_dirs=amrex::Vector< std::string >()) const
write out particular data to an AMReX plotfile
void nonlin_eos(const amrex::Box &bx, const amrex::Array4< amrex::Real const > &state, const amrex::Array4< amrex::Real > &rho, const amrex::Array4< amrex::Real > &rhoA, const amrex::Array4< amrex::Real > &rhoS, const amrex::Array4< amrex::Real > &bvf, const amrex::Array4< amrex::Real > &alpha, const amrex::Array4< amrex::Real > &beta, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &h, const amrex::Array4< amrex::Real const > &mskr, const int N)
Calculate density and related quantities from nonlinear equation of state.
void t3dmix2_geo(const amrex::Box &bx, const amrex::Array4< amrex::Real > &state, const amrex::Array4< amrex::Real > &state_rhs, const amrex::Array4< amrex::Real const > &diff2, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const amrex::Real dt_lev, const int ncomp, const int N)
Harmonic diffusivity for tracers along geopotential surfaces.
std::string plot_file_name
Plotfile prefix.
Definition REMORA.H:1917
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Zt_avg1
Average of the free surface, zeta (2D)
Definition REMORA.H:476
int check_int
Checkpoint output interval in iterations.
Definition REMORA.H:1925
amrex::Real check_cf_tol
tolerance for the above
Definition REMORA.H:1910
void set_smflux(int lev)
Initialize or calculate surface momentum flux from file or analytic.
Definition REMORA.cpp:1602
void WritePlotFile(int istep)
main driver for writing AMReX plotfiles
std::string restart_chkfile
If set, restart from this checkpoint file.
Definition REMORA.H:1783
void average_down_with_grow_cells(int lev, amrex::Vector< std::unique_ptr< amrex::MultiFab > > &mf, bool use_mask=false)
Average down from level lev+1 to lev in mf, including grow cells.
Definition REMORA.cpp:3217
void init_clim_nudg_coeff(int lev)
Wrapper to initialize climatology nudging coefficient.
void init_bathymetry_full_domain_from_analytic()
Full domain bathymetry data initialization from analytic.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv
v velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:432
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_btflx
Bottom tracer flux; working arrays.
Definition REMORA.H:510
int cf_width
Nudging width at coarse-fine interface.
Definition REMORA.H:1637
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real bulk_psit(amrex::Real ZoL)
Evaluate stability function psi for moisture and heat.
Definition REMORA.H:2224
static amrex::Vector< amrex::Vector< std::string > > nc_init_file
NetCDF initialization file.
Definition REMORA.H:59
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_beta
Saline contraction coefficient (3D)
Definition REMORA.H:658
int last_plot_file_step
Step when we last output a plotfile.
Definition REMORA.H:1755
amrex::Vector< std::string > plot_var_names_2d
Names of 2D variables to output to AMReX plotfile.
Definition REMORA.H:1939
int use_biology_cpp_answer
Select the native C++ biology kernel (1) or the ROMS Fortran bridge oracle (0). Only meaningful when ...
Definition REMORA.H:1809
void bulk_fluxes(int lev, amrex::MultiFab *mf_cons, amrex::MultiFab *mf_uwind, amrex::MultiFab *mf_vwind, amrex::MultiFab *mf_Tair, amrex::MultiFab *mf_qair, amrex::MultiFab *mf_Pair, amrex::MultiFab *mf_srflx, amrex::MultiFab *mf_longwave_down, amrex::MultiFab *mf_evap, amrex::MultiFab *mf_sustr, amrex::MultiFab *mf_svstr, amrex::MultiFab *mf_stflux, amrex::MultiFab *mf_lrflx, amrex::MultiFab *mf_lhflx, amrex::MultiFab *mf_shflx, const int N)
Calculate bulk temperature, salinity, wind fluxes.
void t3dmix2_s(const amrex::Box &bx, const amrex::Array4< amrex::Real > &state, const amrex::Array4< amrex::Real > &state_rhs, const amrex::Array4< amrex::Real const > &diff2, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const amrex::Real dt_lev, const int ncomp)
Harmonic diffusivity for tracers along S-coordinate level surfaces.
amrex::Vector< amrex::Real > t_old
old time at each level, in seconds since start_time
Definition REMORA.H:1702
double model_time(amrex::Real elapsed) const noexcept
Time on the model clock, in seconds, of an elapsed time such as t_new.
Definition REMORA.H:2170
void scale_rhs_vars(int lev)
Scale RHS momentum variables by 1/cell area, needed before FillPatch to different levels.
int bio_comp_start() const noexcept
First cons component of the biology block. Problem setups need this to write biology initial conditio...
Definition REMORA.H:2184
int cf_fill_all_kcomp
write every leapfrog record of the coarse-fine ghost band, as put_refine2d does when it sets zeta(:,...
Definition REMORA.H:1876
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr3d
land/sea mask at cell centers, copied to all z levels (3D)
Definition REMORA.H:592
amrex::Vector< amrex::GpuArray< amrex::Real, AMREX_SPACEDIM *2 > > m_bc_extdir_vals
Array holding the Dirichlet values at walls which need them.
Definition REMORA.H:1736
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_srflx
Shortwave radiation flux [W/m²], defined at rho-points.
Definition REMORA.H:495
amrex::Real last_check_file_time
Simulation time when we last output a checkpoint file.
Definition REMORA.H:1762
static amrex::Vector< REMORAErrorTag > ref_tags
Holds info for dynamically generated tagging criteria.
Definition REMORA.H:2066
void append2DPlotVariables(const std::string &pp_plot_var_names_2d)
void set_bathymetry_averaged_down(int lev)
Copy over bathymetry data that has been averaged down from high resolution input netcdf file.
Definition REMORA.cpp:810
amrex::Vector< amrex::Real > dt
time step at each level
Definition REMORA.H:1704
void PackSurfaceState(amrex::Vector< amrex::MultiFab * > &state, amrex::Real time, const amrex::MultiFab *weight_o2a_mf, const amrex::iMultiFab *index_o2a_mf, int max_stencil_size, const amrex::iMultiFab *dst_land_mask=nullptr)
Extracts SST from the 3D conservative state for the atmospheric driver.
static amrex::Real sum_per
Diagnostic sum output interval in time.
Definition REMORA.H:1990
void roll_2d_snapshot(amrex::Vector< std::unique_ptr< amrex::MultiFab > > &old_v, amrex::Vector< std::unique_ptr< amrex::MultiFab > > &new_v, int lev, const amrex::MultiFab &src, const amrex::MultiFab &like)
roll a two-snapshot history of a level's end-of-step 2D state
void set_2d_cf_flux(int lev, amrex::Real time, amrex::MultiFab &mf_DUon, amrex::MultiFab &mf_DVom)
impose the parent's barotropic mass flux on the coarse-fine interface faces
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Pair
Air pressure [mb], defined at rho-points.
Definition REMORA.H:492
void InitializeFromFile()
Read the file passed to remora.restart and use it as an initial condition for the current simulation.
void coriolis(const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &fomn, int nrhs, int nr)
Calculate Coriolis terms.
amrex::Gpu::DeviceVector< amrex::BCRec > domain_bcs_type_d
GPU vector (over BCVars) of BCRecs.
Definition REMORA.H:1730
virtual ~REMORA()
Definition REMORA.cpp:205
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_qair
Specific humidity [kg/kg], defined at rho-points.
Definition REMORA.H:490
int hires_grid_level
Which level the high resolution bathymetry is at.
Definition REMORA.H:2012
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_w
z coordinates at w points (faces between z-cells)
Definition REMORA.H:456
void restart()
Definition REMORA.cpp:695
int reflux_clamp
stop that correction driving a tracer negative, as ROMS does. On by default to match ROMS; costs exac...
Definition REMORA.H:1904
std::unique_ptr< NCTimeSeries > vbar_clim_data_from_file
Data container for vbar climatology data read from file.
Definition REMORA.H:1605
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Tair
Air temperature [°C], defined at rho-points.
Definition REMORA.H:488
void convert_inv_days_to_inv_s(amrex::MultiFab *)
Convert data in a multifab from inverse days to inverse seconds.
const amrex::Vector< std::string > derived_names_2d
Names of derived fields for 2d plotfile fields.
Definition REMORA.H:1946
void average_down_masked(int crse_lev, const amrex::MultiFab &S_fine, amrex::MultiFab &S_crse, const amrex::MultiFab &msk_fine, const amrex::MultiFab &cmsk, int ncomp, int face_dir)
Definition REMORA.cpp:3057
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yr
y_grid on rho points (2D)
Definition REMORA.H:617
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Hvom
v-volume flux (3D)
Definition REMORA.H:428
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akp
Turbulent length scale vertical diffusion coefficient.
Definition REMORA.H:675
void gls_corrector(int lev, amrex::MultiFab *mf_gls, amrex::MultiFab *mf_tke, amrex::MultiFab &mf_W, amrex::MultiFab *mf_Akv, amrex::MultiFab *mf_Akt, amrex::MultiFab *mf_Akk, amrex::MultiFab *mf_Akp, amrex::MultiFab *mf_mskr, amrex::MultiFab *mf_msku, amrex::MultiFab *mf_mskv, const int nstp, const int nnew, const int N, const amrex::Real dt_lev)
Corrector step for GLS calculation.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_diff2
Harmonic diffusivity for temperature / salinity.
Definition REMORA.H:450
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_latp
latitude on psi-points (2D, degrees north); only filled when the grid NetCDF file carries lat_psi
Definition REMORA.H:639
REMORABiology::BiologyICType biology_ic_type
Source of the biology tracer initial condition, independent of remora.ic_type. Default follows ic_typ...
Definition REMORA.H:1804
int NumTypes(int ncons) noexcept
int xvel_bc(int ncons) noexcept
int zvel_bc(int ncons) noexcept
int yvel_bc(int ncons) noexcept
int vbar_bc(int ncons) noexcept
int foextrap_bc(int ncons) noexcept
int v2d_simple_bc(int ncons) noexcept
int u2d_simple_bc(int ncons) noexcept
int zeta_bc(int ncons) noexcept
int ubar_bc(int ncons) noexcept
int tke_bc(int ncons) noexcept
int foextrap_periodic_bc(int ncons) noexcept
int NumTypes(int ncons) noexcept
int vbar(int ncons) noexcept
int cons(int icomp) noexcept
static constexpr int null
int zeta(int ncons) noexcept
int ubar(int ncons) noexcept
@ CellConservativeQuartic
Definition REMORA.H:76
@ CellBilinear
Definition REMORA.H:73
@ PCInterp
Definition REMORA.H:70
@ NodeBilinear
Definition REMORA.H:71
@ CellConservativeLinear
Definition REMORA.H:72
@ CellQuadratic
Definition REMORA.H:74
@ CellConservativeProtected
Definition REMORA.H:75
@ follow_ic_type
default: NetCDF when ic_type is netcdf, else analytic
Coordinates a prob function reads, on the BoxArray and DistributionMapping of the MultiFab it fills.