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 void check_plot_nodal_z (const amrex::Vector<const amrex::MultiFab*>& nd,
708 const amrex::Vector<amrex::Geometry>& g);
709
710 /** \brief Physical (x, y) of the psi points on every level, for plotfile output */
711 void plot_node_coords (amrex::Vector<amrex::MultiFab>& mf_xy);
712
713 /** \brief Set everything up for a step on a level */
714 void setup_step(int lev, amrex::Real time, amrex::Real dt_lev);
715
716 /** \brief 3D advance on a single level */
717 void advance_3d_ml (int lev, amrex::Real dt_lev);
718
719 /** \brief 2D advance, one predictor/corrector step */
720 void advance_2d_onestep (int lev, amrex::Real dt_lev, amrex::Real dtfast_lev, int my_iif, int nfast_counter);
721
722 /** \brief Perform a 2D predictor (predictor_2d_step=True) or corrector (predictor_2d_step=False) step */
723 void advance_2d (int lev,
724 amrex::MultiFab const* mf_rhoS,
725 amrex::MultiFab const* mf_rhoA,
726 amrex::MultiFab * mf_ru2d,
727 amrex::MultiFab * mf_rv2d,
728 amrex::MultiFab * mf_rufrc,
729 amrex::MultiFab * mf_rvfrc,
730 amrex::MultiFab * mf_Zt_avg1,
731 std::unique_ptr<amrex::MultiFab>& mf_DU_avg1,
732 std::unique_ptr<amrex::MultiFab>& mf_DU_avg2,
733 std::unique_ptr<amrex::MultiFab>& mf_DV_avg1,
734 std::unique_ptr<amrex::MultiFab>& mf_DV_avg2,
735 std::unique_ptr<amrex::MultiFab>& mf_rubar,
736 std::unique_ptr<amrex::MultiFab>& mf_rvbar,
737 std::unique_ptr<amrex::MultiFab>& mf_rzeta,
738 std::unique_ptr<amrex::MultiFab>& mf_ubar,
739 std::unique_ptr<amrex::MultiFab>& mf_vbar,
740 amrex::MultiFab * mf_zeta,
741 amrex::MultiFab const* mf_h,
742 amrex::MultiFab const* mf_pm,
743 amrex::MultiFab const* mf_pn,
744 amrex::MultiFab const* mf_fcor,
745 amrex::MultiFab const* mf_visc2_p,
746 amrex::MultiFab const* mf_visc2_r,
747 amrex::MultiFab const* mf_mskr,
748 amrex::MultiFab const* mf_msku,
749 amrex::MultiFab const* mf_mskv,
750 amrex::MultiFab const* mf_mskp,
751 amrex::Real dtfast_lev,
753 bool first_2d_step, int my_iif,
754 int & next_indx1);
755
756 /** \brief Advance the 3D variables */
757 void advance_3d (int lev,
758 amrex::MultiFab& mf_cons,
759 amrex::MultiFab& mf_u , amrex::MultiFab& mf_v,
760 amrex::MultiFab* mf_sstore,
761 amrex::MultiFab* mf_ru , amrex::MultiFab* mf_rv,
762 std::unique_ptr<amrex::MultiFab>& mf_DU_avg1,
763 std::unique_ptr<amrex::MultiFab>& mf_DU_avg2,
764 std::unique_ptr<amrex::MultiFab>& mf_DV_avg1,
765 std::unique_ptr<amrex::MultiFab>& mf_DV_avg2,
766 std::unique_ptr<amrex::MultiFab>& mf_ubar,
767 std::unique_ptr<amrex::MultiFab>& mf_vbar,
768 std::unique_ptr<amrex::MultiFab>& mf_Akv,
769 std::unique_ptr<amrex::MultiFab>& mf_Akt,
770 std::unique_ptr<amrex::MultiFab>& mf_Hz,
771 std::unique_ptr<amrex::MultiFab>& mf_Huon,
772 std::unique_ptr<amrex::MultiFab>& mf_Hvom,
773 std::unique_ptr<amrex::MultiFab>& mf_z_w,
774 amrex::MultiFab const* mf_h,
775 amrex::MultiFab const* mf_pm,
776 amrex::MultiFab const* mf_pn,
777 amrex::MultiFab const* mf_mskr,
778 amrex::MultiFab const* mf_msku,
779 amrex::MultiFab const* mf_mskv,
780 const int N,
781 const amrex::Real dt_lev);
782
783 /** \brief Apply biological tracer source/sink terms */
784 void advance_biology (int lev, amrex::MultiFab const& mf_cons_old,
785 amrex::MultiFab& mf_cons_new,
786 int N, amrex::Real dt_lev);
787
788#ifdef REMORA_USE_FENNEL_FORT
789 /** \brief Path A oracle: apply biological source/sink terms through the
790 * ROMS Fennel Fortran kernel. Selected at run time by
791 * remora.use_biology_cpp_answer = 0. */
792 void advance_biology_fortran (int lev, amrex::MultiFab const& mf_cons_old,
793 amrex::MultiFab& mf_cons_new,
794 int N, amrex::Real dt_lev);
795#endif
796
797 /** \brief Calculate bulk temperature, salinity, wind fluxes */
798 void bulk_fluxes (int lev,
799 amrex::MultiFab* mf_cons,
800 amrex::MultiFab* mf_uwind,
801 amrex::MultiFab* mf_vwind,
802 amrex::MultiFab* mf_Tair,
803 amrex::MultiFab* mf_qair,
804 amrex::MultiFab* mf_Pair,
805 amrex::MultiFab* mf_srflx,
806 amrex::MultiFab* mf_longwave_down,
807 amrex::MultiFab* mf_evap,
808 amrex::MultiFab* mf_sustr,
809 amrex::MultiFab* mf_svstr,
810 amrex::MultiFab* mf_stflux,
811 amrex::MultiFab* mf_lrflx,
812 amrex::MultiFab* mf_lhflx,
813 amrex::MultiFab* mf_shflx,
814 const int N);
815
816 /** \brief Wrapper function for prestep */
817 void prestep (int lev,
818 amrex::MultiFab& mf_uold, amrex::MultiFab& mf_vold,
819 amrex::MultiFab& mf_u, amrex::MultiFab& mf_v,
820 amrex::MultiFab* mf_ru,
821 amrex::MultiFab* mf_rv,
822 amrex::MultiFab& S_old,
823 amrex::MultiFab& S_new,
824 amrex::MultiFab& mf_W, amrex::MultiFab& mf_DC,
825 /* MF mf_FC? */
826 const amrex::MultiFab* mf_z_r,
827 const amrex::MultiFab* mf_z_w,
828 const amrex::MultiFab* mf_h,
829 const amrex::MultiFab* mf_pm,
830 const amrex::MultiFab* mf_pn,
831 const amrex::MultiFab* mf_sustr,
832 const amrex::MultiFab* mf_svstr,
833 const amrex::MultiFab* mf_bustr,
834 const amrex::MultiFab* mf_bvstr,
835 const amrex::MultiFab* mf_msku,
836 const amrex::MultiFab* mf_mskv,
837 const int iic, const int nfirst,
838 const int nnew, int nstp, int nrhs,
839 int N, const amrex::Real dt_lev);
840
841 /** \brief Prestep advection calculations for the tracers */
842 void prestep_t_advection (int lev, const amrex::Box& tbx,
843 const amrex::Box& gbx,
844 const amrex::Array4<amrex::Real >& tempold,
845 const amrex::Array4<amrex::Real >& tempcache,
846 const amrex::Array4<amrex::Real >& Hz,
847 const amrex::Array4<amrex::Real >& Huon,
848 const amrex::Array4<amrex::Real >& Hvom,
849 const amrex::Array4<amrex::Real >& W,
850 const amrex::Array4<amrex::Real >& DC,
851 const amrex::Array4<amrex::Real >& FC,
852 const amrex::Array4<amrex::Real >& sstore,
853 const amrex::Array4<amrex::Real const>& z_w,
854 const amrex::Array4<amrex::Real const>& h,
855 const amrex::Array4<amrex::Real const>& pm,
856 const amrex::Array4<amrex::Real const>& pn,
857 const amrex::Array4<amrex::Real const>& msku,
858 const amrex::Array4<amrex::Real const>& mskv,
859 const amrex::Array4<int const>& river_pos,
860 const amrex::Array4<amrex::Real const>& river_source,
861 int iic, int ntfirst, int nrhs, int N,
862 const amrex::Real dt_lev);
863
864 /** \brief RHS terms for tracer */
865 void rhs_t_3d (int lev,
866 const amrex::Box& bx,
867 const amrex::Array4<amrex::Real >& t,
868 const amrex::Array4<amrex::Real const>& tempstore,
869 const amrex::Array4<amrex::Real const>& Huon,
870 const amrex::Array4<amrex::Real const>& Hvom,
871 const amrex::Array4<amrex::Real const>& Hz,
872 const amrex::Array4<amrex::Real const>& pn,
873 const amrex::Array4<amrex::Real const>& pm,
874 const amrex::Array4<amrex::Real const>& W,
875 const amrex::Array4<amrex::Real >& FC,
876 const amrex::Array4<amrex::Real const>& mskr,
877 const amrex::Array4<amrex::Real const>& msku,
878 const amrex::Array4<amrex::Real const>& mskv,
879 const amrex::Array4<int const>& river_pos,
880 const amrex::Array4<amrex::Real const>& river_source,
881 int nrhs, int nnew, int N, const amrex::Real dt_lev,
882 const amrex::Array4<amrex::Real>& fx_reg = amrex::Array4<amrex::Real>(),
883 const amrex::Array4<amrex::Real>& fy_reg = amrex::Array4<amrex::Real>());
884
885 /** \brief RHS terms for 3D momentum */
886 void rhs_uv_3d (int lev,
887 const amrex::Box& xbx,
888 const amrex::Box& ybx,
889 const amrex::Array4<amrex::Real const>& uold,
890 const amrex::Array4<amrex::Real const>& vold,
891 const amrex::Array4<amrex::Real >& ru,
892 const amrex::Array4<amrex::Real >& rv,
893 const amrex::Array4<amrex::Real >& rufrc,
894 const amrex::Array4<amrex::Real >& rvfrc,
895 const amrex::Array4<amrex::Real const>& sustr,
896 const amrex::Array4<amrex::Real const>& svstr,
897 const amrex::Array4<amrex::Real const>& bustr,
898 const amrex::Array4<amrex::Real const>& bvstr,
899 const amrex::Array4<amrex::Real const>& Huon,
900 const amrex::Array4<amrex::Real const>& Hvom,
901 const amrex::Array4<amrex::Real const>& pm,
902 const amrex::Array4<amrex::Real const>& pn,
903 const amrex::Array4<amrex::Real const>& W,
904 const amrex::Array4<amrex::Real >& FC,
905 int nrhs, int N);
906
907 /** \brief RHS terms for 2D momentum */
908 void rhs_uv_2d (int lev,
909 const amrex::Box& xbx,
910 const amrex::Box& ybx,
911 const amrex::Array4<amrex::Real const>& uold,
912 const amrex::Array4<amrex::Real const>& vold,
913 const amrex::Array4<amrex::Real >& ru,
914 const amrex::Array4<amrex::Real >& rv,
915 const amrex::Array4<amrex::Real const>& Duon,
916 const amrex::Array4<amrex::Real const>& Dvom,
917 const int nrhs);
918
919 /** \brief Wrapper around equation of state calculation */
920 void rho_eos (const amrex::Box& bx,
921 const amrex::Array4<amrex::Real const>& state,
922 const amrex::Array4<amrex::Real >& rho,
923 const amrex::Array4<amrex::Real >& rhoA,
924 const amrex::Array4<amrex::Real >& rhoS,
925 const amrex::Array4<amrex::Real >& bvf,
926 const amrex::Array4<amrex::Real >& alpha,
927 const amrex::Array4<amrex::Real >& beta,
928 const amrex::Array4<amrex::Real const>& Hz,
929 const amrex::Array4<amrex::Real const>& z_w,
930 const amrex::Array4<amrex::Real const>& z_r,
931 const amrex::Array4<amrex::Real const>& h,
932 const amrex::Array4<amrex::Real const>& mskr,
933 const int N);
934
935 /** \brief Calculate density and related quantities from linear equation of state */
936 void lin_eos (const amrex::Box& bx,
937 const amrex::Array4<amrex::Real const>& state,
938 const amrex::Array4<amrex::Real >& rho,
939 const amrex::Array4<amrex::Real >& rhoA,
940 const amrex::Array4<amrex::Real >& rhoS,
941 const amrex::Array4<amrex::Real >& bvf,
942 const amrex::Array4<amrex::Real const>& Hz,
943 const amrex::Array4<amrex::Real const>& z_w,
944 const amrex::Array4<amrex::Real const>& z_r,
945 const amrex::Array4<amrex::Real const>& h,
946 const amrex::Array4<amrex::Real const>& mskr,
947 const int N);
948
949 /** \brief Calculate density and related quantities from nonlinear equation of state */
950 void nonlin_eos (const amrex::Box& bx,
951 const amrex::Array4<amrex::Real const>& state,
952 const amrex::Array4<amrex::Real >& rho,
953 const amrex::Array4<amrex::Real >& rhoA,
954 const amrex::Array4<amrex::Real >& rhoS,
955 const amrex::Array4<amrex::Real >& bvf,
956 const amrex::Array4<amrex::Real >& alpha,
957 const amrex::Array4<amrex::Real >& beta,
958 const amrex::Array4<amrex::Real const>& Hz,
959 const amrex::Array4<amrex::Real const>& z_w,
960 const amrex::Array4<amrex::Real const>& z_r,
961 const amrex::Array4<amrex::Real const>& h,
962 const amrex::Array4<amrex::Real const>& mskr,
963 const int N);
964
965 /** \brief Calculate pressure gradient */
966 void prsgrd (const amrex::Box& bx,
967 const amrex::Box& gbx,
968 const amrex::Box& utbx,
969 const amrex::Box& vtbx,
970 const amrex::Array4<amrex::Real >& ru,
971 const amrex::Array4<amrex::Real >& rv,
972 const amrex::Array4<amrex::Real const>& pn,
973 const amrex::Array4<amrex::Real const>& pm,
974 const amrex::Array4<amrex::Real const>& rho,
975 const amrex::Array4<amrex::Real >& FC,
976 const amrex::Array4<amrex::Real const>& Hz,
977 const amrex::Array4<amrex::Real const>& z_r,
978 const amrex::Array4<amrex::Real const>& z_w,
979 const amrex::Array4<amrex::Real const>& msku,
980 const amrex::Array4<amrex::Real const>& mskv,
981 const int nrhs, const int N);
982
983 /** \brief Update velocities or tracers with diffusion/viscosity
984 * as the last part of the prestep */
985 void prestep_diffusion (const amrex::Box& bx,
986 const amrex::Box& gbx,
987 const int ioff, const int joff,
988 const amrex::Array4<amrex::Real >& vel,
989 const amrex::Array4<amrex::Real const>& vel_old,
990 const amrex::Array4<amrex::Real >& rvel,
991 const amrex::Array4<amrex::Real const>& Hz,
992 const amrex::Array4<amrex::Real const>& Akv,
993 const amrex::Array4<amrex::Real >& FC,
994 const amrex::Array4<amrex::Real const>& sstr,
995 const amrex::Array4<amrex::Real const>& bstr,
996 const amrex::Array4<amrex::Real const>& z_r,
997 const amrex::Array4<amrex::Real const>& pm,
998 const amrex::Array4<amrex::Real const>& pn,
999 const int iic, const int ntfirst, const int nnew, int nstp, int nrhs, int N,
1000 const amrex::Real lambda, const amrex::Real dt_lev);
1001
1002 /** \brief Calculate effects of vertical viscosity or diffusivity */
1003 void vert_visc_3d (const amrex::Box& bx,
1004 const int ioff, const int joff,
1005 const amrex::Array4<amrex::Real >& phi,
1006 const amrex::Array4<amrex::Real const>& Hz,
1007 const amrex::Array4<amrex::Real >& Hzk,
1008 const amrex::Array4<amrex::Real >& AK,
1009 const amrex::Array4<amrex::Real const>& Akv,
1010 const amrex::Array4<amrex::Real >& BC,
1011 const amrex::Array4<amrex::Real >& DC,
1012 const amrex::Array4<amrex::Real >& FC,
1013 const amrex::Array4<amrex::Real >& CF,
1014 const int nnew, const int N,
1015 const amrex::Real dt_lev);
1016
1017 /** \brief Vertical volume flux W from the horizontal mass flux divergence */
1018 static void compute_W (const amrex::Box& bx2d,
1019 const amrex::Array4<amrex::Real >& W,
1020 const amrex::Array4<amrex::Real const>& Huon,
1021 const amrex::Array4<amrex::Real const>& Hvom,
1022 const amrex::Array4<amrex::Real const>& z_w,
1023 const amrex::Array4<amrex::Real const>& h,
1024 const int N);
1025
1026 /** \brief Velocity across the w-levels (omega, m/s) from the given mass fluxes */
1027 void compute_omega (int lev, amrex::MultiFab& mf_omega,
1028 const amrex::MultiFab& mf_Huon, const amrex::MultiFab& mf_Hvom);
1029
1030 /** \brief omega (m/s) as ROMS writes it: from mass fluxes of the current velocities */
1031 void compute_diagnostic_omega (int lev, amrex::MultiFab& mf_omega);
1032
1033 /** \brief "True" vertical velocity w (m/s) at w-points, as ROMS wvelocity */
1034 void compute_wvel (int lev, amrex::MultiFab& mf_w);
1035
1036 /** \brief As compute_wvel, from an omega already computed by compute_diagnostic_omega */
1037 void compute_wvel (int lev, amrex::MultiFab& mf_w, const amrex::MultiFab& mf_omega);
1038
1039 /** \brief omega and w on the s_w points of the NetCDF output, ghost columns filled and masked */
1040 void compute_omega_and_w (int lev, amrex::MultiFab* mf_omega, amrex::MultiFab* mf_wvel);
1041
1042 /** \brief Horizontal mass fluxes Hz*u/n and Hz*v/m of the current velocities, as ROMS set_massflux */
1043 void set_massflux_3d (int lev, amrex::MultiFab& mf_Huon, amrex::MultiFab& mf_Hvom);
1044
1045 /** \brief Correct mass flux */
1046 void update_massflux_3d (int lev, const amrex::Box& bx,
1047 const int ioff, const int joff,
1048 const amrex::Array4<amrex::Real >& phi,
1049 const amrex::Array4<amrex::Real >& phibar,
1050 const amrex::Array4<amrex::Real >& Hphi,
1051 const amrex::Array4<amrex::Real const>& Hz,
1052 const amrex::Array4<amrex::Real const>& pm_or_pn,
1053 const amrex::Array4<amrex::Real const>& Dphi1,
1054 const amrex::Array4<amrex::Real const>& Dphi2,
1055 const amrex::Array4<amrex::Real >& DC,
1056 const amrex::Array4<amrex::Real >& FC,
1057 const amrex::Array4<amrex::Real const>& msk,
1058 const int nnew);
1059
1060 /** \brief Adjust 3D momentum variables based on vertical mean momentum */
1061 void vert_mean_3d (const amrex::Box& bx,
1062 const int ioff, const int joff,
1063 const amrex::Array4<amrex::Real >& phi,
1064 const amrex::Array4<amrex::Real const>& Hz,
1065 const amrex::Array4<amrex::Real const>& Dphi_avg1,
1066 const amrex::Array4<amrex::Real >& DC,
1067 const amrex::Array4<amrex::Real >& CF,
1068 const amrex::Array4<amrex::Real const>& pm_or_pn,
1069 const amrex::Array4<amrex::Real const>& msk,
1070 const int nnew, const int N);
1071
1072 /** \brief Harmonic viscosity */
1073 void uv3dmix (const amrex::Box& xbx,
1074 const amrex::Box& ybx,
1075 const amrex::Array4<amrex::Real >& u,
1076 const amrex::Array4<amrex::Real >& v,
1077 const amrex::Array4<amrex::Real const>& uold,
1078 const amrex::Array4<amrex::Real const>& vold,
1079 const amrex::Array4<amrex::Real >& rufrc,
1080 const amrex::Array4<amrex::Real >& rvfrc,
1081 const amrex::Array4<amrex::Real const>& visc2_p,
1082 const amrex::Array4<amrex::Real const>& visc2_r,
1083 const amrex::Array4<amrex::Real const>& Hz,
1084 const amrex::Array4<amrex::Real const>& pm,
1085 const amrex::Array4<amrex::Real const>& pn,
1086 const amrex::Array4<amrex::Real const>& mskp,
1087 int nrhs, int nnew,
1088 const amrex::Real dt_lev);
1089
1090 /** \brief Wrapper for harmonic diffusivity for tracers */
1091 void t3dmix2 (const amrex::Box& bx,
1092 const amrex::Array4<amrex::Real >& state,
1093 const amrex::Array4<amrex::Real >& state_rhs,
1094 const amrex::Array4<amrex::Real const>& diff2,
1095 const amrex::Array4<amrex::Real const>& Hz,
1096 const amrex::Array4<amrex::Real const>& z_r,
1097 const amrex::Array4<amrex::Real const>& pm,
1098 const amrex::Array4<amrex::Real const>& pn,
1099 const amrex::Array4<amrex::Real const>& msku,
1100 const amrex::Array4<amrex::Real const>& mskv,
1101 const amrex::Real dt_lev,
1102 const int ncomp, const int N);
1103
1104 /** \brief Harmonic diffusivity for tracers along S-coordinate level surfaces */
1105 void t3dmix2_s(const amrex::Box& bx,
1106 const amrex::Array4<amrex::Real >& state,
1107 const amrex::Array4<amrex::Real >& state_rhs,
1108 const amrex::Array4<amrex::Real const>& diff2,
1109 const amrex::Array4<amrex::Real const>& Hz,
1110 const amrex::Array4<amrex::Real const>& pm,
1111 const amrex::Array4<amrex::Real const>& pn,
1112 const amrex::Array4<amrex::Real const>& msku,
1113 const amrex::Array4<amrex::Real const>& mskv,
1114 const amrex::Real dt_lev, const int ncomp);
1115
1116 /** \brief Harmonic diffusivity for tracers along geopotential surfaces */
1117 void t3dmix2_geo (const amrex::Box& bx,
1118 const amrex::Array4<amrex::Real >& state,
1119 const amrex::Array4<amrex::Real >& state_rhs,
1120 const amrex::Array4<amrex::Real const>& diff2,
1121 const amrex::Array4<amrex::Real const>& Hz,
1122 const amrex::Array4<amrex::Real const>& z_r,
1123 const amrex::Array4<amrex::Real const>& pm,
1124 const amrex::Array4<amrex::Real const>& pn,
1125 const amrex::Array4<amrex::Real const>& msku,
1126 const amrex::Array4<amrex::Real const>& mskv,
1127 const amrex::Real dt_lev,
1128 const int ncomp, const int N);
1129
1130 /** \brief Calculate Coriolis terms */
1131 void coriolis (const amrex::Box& xbx,
1132 const amrex::Box& ybx,
1133 const amrex::Array4<amrex::Real const>& uold,
1134 const amrex::Array4<amrex::Real const>& vold,
1135 const amrex::Array4<amrex::Real >& ru,
1136 const amrex::Array4<amrex::Real >& rv,
1137 const amrex::Array4<amrex::Real const>& Hz,
1138 const amrex::Array4<amrex::Real const>& fomn,
1139 int nrhs, int nr);
1140
1141 /** \brief Calculate curvilinear advection terms */
1142 void curvilinear (const amrex::Box& bx,
1143 const amrex::Box& xbx,
1144 const amrex::Box& ybx,
1145 const amrex::Array4<amrex::Real const>& uold,
1146 const amrex::Array4<amrex::Real const>& vold,
1147 const amrex::Array4<amrex::Real >& ru,
1148 const amrex::Array4<amrex::Real >& rv,
1149 const amrex::Array4<amrex::Real const>& Hz,
1150 const amrex::Array4<amrex::Real const>& dndx,
1151 const amrex::Array4<amrex::Real const>& dmde,
1152 int nrhs, int nr);
1153
1154 /** \brief Shrink an x- or y-nodal momentum tilebox to the faces ROMS nudges
1155 *
1156 * ROMS nudges momentum toward climatology over i=IstrU..Iend (j=JstrV..Jend), which
1157 * excludes the u-face on the western and eastern domain edges (v-face on the southern
1158 * and northern edges). This returns the part of \p nodal_bx that survives that
1159 * exclusion. Under EW_PERIODIC (NS_PERIODIC) ROMS sets IstrU=Istr (JstrV=Jstr) and
1160 * nudges every face, so a periodic direction is left alone.
1161 *
1162 * @param[in] nodal_bx box from MFIter::nodaltilebox(dir)
1163 * @param[in] dir direction the box is nodal in (0 for u, 1 for v)
1164 * @param[in] domain cell-centered problem domain at this level
1165 * @param[in] is_periodic whether \p dir is periodic
1166 */
1167 static amrex::Box clim_nudg_momentum_box (const amrex::Box& nodal_bx,
1168 int dir,
1169 const amrex::Box& domain,
1170 bool is_periodic);
1171
1172 /** \brief Apply climatology nudging */
1173 void apply_clim_nudg (const amrex::Box& bx,
1174 int ioff, int joff,
1175 const amrex::Array4<amrex::Real >& var,
1176 const amrex::Array4<amrex::Real const>& var_old,
1177 const amrex::Array4<amrex::Real const>& var_clim,
1178 const amrex::Array4<amrex::Real const>& clim_coeff,
1179 const amrex::Array4<amrex::Real const>& Hz,
1180 const amrex::Array4<amrex::Real const>& pm,
1181 const amrex::Array4<amrex::Real const>& pn,
1182 const amrex::Real dt_lev = zero);
1183
1184 /** \brief Set 2D momentum arrays from 3D momentum */
1185 void set_2darrays (int lev);
1186
1187 /** \brief Set Zt_avg1 to zeta */
1188 void set_zeta_average (int lev);
1189
1190 /** \brief Initialize zeta from file or analytic */
1191 void set_zeta (int lev);
1192
1193 /** \brief Copy over zeta data that has been averaged down from high res */
1194 void set_zeta_averaged_down (int lev);
1195
1196 /** \brief Initialize bathymetry from file or analytic */
1197 void set_bathymetry (int lev);
1198
1199 /** \brief Copy over bathymetry data that has been averaged down from high resolution
1200 * input netcdf file */
1202
1203 /** \brief Initialize Coriolis factor from file or analytic */
1204 void set_coriolis (int lev);
1205
1206 /** \brief Initialize land-sea masks from file or analytic */
1207 void set_masks (int lev);
1208
1209 /** \brief Copy this level's land-sea mask out of the full-domain mask that was coarsened
1210 * down from hires_grid_level */
1211 void set_masks_averaged_down (int lev);
1212
1213 /** \brief Coarsen the full-domain rho-mask from crse_lev+1 onto crse_lev, grow cells
1214 * included, by the rule that a coarse cell is land only if all its fine cells are land */
1216
1217 /** \brief Coarsen the full-domain bathymetry from crse_lev+1 onto crse_lev, grow cells
1218 * included, weighted by the land/sea mask */
1220
1221 /** \brief Inject the full-domain rho-mask from fine_lev-1 onto fine_lev, piecewise
1222 * constant, grow cells included */
1224
1225 /** \brief Make sure the full-domain rho-mask exists on levels 0 through top_lev */
1227
1228 /** \brief Rebuild the u-, v- and psi-point masks from vec_mskr and fill their ghosts */
1229 void update_nodal_masks (int lev);
1230
1231 /** \brief Give lev's rho-mask ghost cells beyond the domain the coarser level's values */
1233
1234 /** \brief Make sure the coarse masks the average-down kernels read sit on the coarsened
1235 * layout of level crse_lev+1, rebuilding them if a regrid has moved it */
1236 void update_avgdown_masks (int crse_lev);
1237
1238 /** \brief Drop the cached average-down masks of every level pair that involves lev */
1239 void clear_avgdown_masks (int lev);
1240
1241 /** \brief Check every level pair's masks against each other, and every level's mask
1242 * values, reporting according to remora.mask_consistency */
1243 void check_mask_consistency ();
1244
1245 /** \brief Calculate vertical stretched coordinates */
1246 void stretch_transform (int lev);
1247
1248 /** \brief Calculate z_r and z_w on full-domain arrays at a level not yet created */
1249 void stretch_transform_full_domain (int lev, const amrex::MultiFab& mf_h,
1250 const amrex::MultiFab& mf_zeta,
1251 amrex::MultiFab& mf_z_r, amrex::MultiFab& mf_z_w);
1252
1253 /** \brief Initialize vertical mixing coefficients from file or analytic */
1254 void init_set_vmix (int lev);
1255 /** \brief Set vertical mixing coefficients from analytic */
1256 void set_analytic_vmix (int lev);
1257 /** \brief Initialize GLS variables */
1259 /** \brief Prestep for GLS calculation */
1260 void gls_prestep (int lev, amrex::MultiFab* mf_gls, amrex::MultiFab* mf_tke,
1261 amrex::MultiFab& mf_W,
1262 amrex::MultiFab* mf_msku, amrex::MultiFab* mf_mskv,
1263 const int nstp, const int nnew, const int iic, const int ntfirst,
1264 const int N, const amrex::Real dt_lev);
1265 /** \brief Corrector step for GLS calculation */
1266 void gls_corrector (int lev, amrex::MultiFab* mf_gls, amrex::MultiFab* mf_tke,
1267 amrex::MultiFab& mf_W, amrex::MultiFab* mf_Akv, amrex::MultiFab* mf_Akt,
1268 amrex::MultiFab* mf_Akk, amrex::MultiFab* mf_Akp,
1269 amrex::MultiFab* mf_mskr,
1270 amrex::MultiFab* mf_msku, amrex::MultiFab* mf_mskv,
1271 const int nstp, const int nnew,
1272 const int N, const amrex::Real dt_lev);
1273
1274 /** \brief Scale RHS momentum variables by 1/cell area, needed before FillPatch to different levels*/
1275 void scale_rhs_vars (int lev);
1276 /** \brief Scale RHS momentum variables by cell area, needed after FillPatch to different levels*/
1277 void scale_rhs_vars_inv (int lev);
1278
1279 /** \brief Initialize or calculate surface momentum flux from file or analytic */
1280 void set_smflux (int lev);
1281
1282 /** \brief Initialize or calculate wind speed and other surface state vars from file or analytic */
1283 void set_surface_state (int lev);
1284
1285 /** \brief Initialize horizontal mixing coefficients */
1286 void set_hmixcoef (int lev);
1287
1288 /** \brief Initialize or calculate bottom drag */
1289 void set_drag (int lev);
1290
1291 /** \brief Set weights for averaging 3D variables to 2D */
1292 void set_weights (int lev);
1293
1294 /** \brief Fill the physical boundary conditions for cell-centered velocity (diagnostic only) */
1295 void FillBdyCCVels (int lev, amrex::MultiFab& mf_cc_vel);
1296
1297 /** \brief Fill a new MultiFab by copying in phi from valid region and filling ghost cells */
1298 void FillPatch (int lev, amrex::Real time,
1299 amrex::MultiFab& mf_to_be_filled,
1300 amrex::Vector<amrex::MultiFab*> const& mfs,
1301 const int bccomp,
1302 const int bdy_var_type = BdyVars::null,
1303 const int icomp=0,
1304 const bool fill_all=true,
1305 const bool fill_set=false,
1306 const int n_not_fill=0,
1307 const int icomp_calc=0,
1308 const amrex::Real dt = zero,
1309 const amrex::MultiFab& mf_calc = amrex::MultiFab(),
1310 amrex::Vector<amrex::MultiFab*> const& mfs_crse_old = {},
1311 amrex::Vector<amrex::MultiFab*> const& mfs_crse_new = {});
1312
1313 /** \brief Fill a new MultiFab by copying in phi from valid region and filling ghost cells without applying boundary conditions */
1314 void FillPatchNoBC (int lev, amrex::Real time,
1315 amrex::MultiFab& mf_to_be_filled,
1316 amrex::Vector<amrex::MultiFab*> const& mfs,
1317 const int bdy_var_type = BdyVars::null,
1318 const int icomp=0,
1319 const bool fill_all=true,
1320 const bool fill_set=false,
1321 amrex::Vector<amrex::MultiFab*> const& mfs_crse_old = {},
1322 amrex::Vector<amrex::MultiFab*> const& mfs_crse_new = {});
1323 /** \brief Fill boundary data from netcdf file */
1324 void fill_from_bdyfiles (int lev,
1325 amrex::MultiFab& mf_to_fill,
1326 const amrex::MultiFab& mf_mask,
1327 const amrex::Real time,
1328 const int bccomp,
1329 const int bdy_var_type,
1330 const int icomp_to_fill,
1331 const int icomp_calc = 0,
1332 const amrex::MultiFab& mf_calc = amrex::MultiFab(),
1333 const amrex::Real = zero);
1334
1335 /** \brief fill an entire multifab by interpolating from the coarser level
1336 * using the piecewise constant interpolater */
1337 void FillCoarsePatchPC (int lev, amrex::Real time, amrex::MultiFab* mf_fine,
1338 amrex::MultiFab* mf_crse,
1339 const int bccomp,
1340 const int bdy_var_type = BdyVars::null,
1341 const int icomp = 0,
1342 const bool fill_all = true,
1343 const int n_not_fill=0,
1344 const int icomp_calc=0,
1345 const amrex::Real dt = zero,
1346 const amrex::MultiFab& mf_calc = amrex::MultiFab());
1347
1348 /** \brief fill an entire multifab by interpolating from the coarser level */
1349 void FillCoarsePatch (int lev, amrex::Real time, amrex::MultiFab* mf_fine,
1350 amrex::MultiFab* mf_crse,
1351 const int bccomp,
1352 const int bdy_var_type = BdyVars::null,
1353 const int icomp = 0,
1354 const bool fill_all = true,
1355 const int n_not_fill=0,
1356 const int icomp_calc=0,
1357 const amrex::Real dt = zero,
1358 const amrex::MultiFab& mf_calc = amrex::MultiFab());
1359
1360 /** \brief fill an entire multifab by interpolating from the coarser level,
1361 * explicitly specifying interpolator to use */
1362 void FillCoarsePatchMap (int lev, amrex::Real time, amrex::MultiFab* mf_fine,
1363 amrex::MultiFab* mf_crse,
1364 const int bccomp,
1365 const int bdy_var_type = BdyVars::null,
1366 const int icomp = 0,
1367 const bool fill_all = true,
1368 const int n_not_fill=0,
1369 const int icomp_calc=0,
1370 const amrex::Real dt = zero,
1371 const amrex::MultiFab& mf_calc = amrex::MultiFab(),
1372 amrex::Interpolater* mapper = nullptr);
1373
1374 /** \brief initialize and calculate stretch coefficients */
1375 void init_stretch_coeffs ();
1376 /** \brief calculate vertical stretch coefficients */
1377 void calc_stretch_coeffs ();
1378
1379 /** \brief Calculate Coriolis parameters from beta plane parametrization */
1380 void init_beta_plane_coriolis (int lev);
1381
1382 /** \brief Full domain bathymetry data initialization from analytic */
1384
1385 /** \brief Full domain land-sea mask initialization from analytic */
1387
1388 /** \brief Problem initialization from averaged-down high resolution data */
1390 /** \brief Problem initialization from NetCDF file */
1391 void init_data_from_netcdf (int lev);
1392 /** \brief Biology initialization from NetCDF file */
1393 void init_biology_from_netcdf (int lev);
1394 /** \brief Passive (dye) scalar initialization from NetCDF file. Called from
1395 * init_data_from_netcdf: dye follows remora.ic_type rather than having
1396 * a source flag of its own. */
1397 void init_scalars_from_netcdf (int lev);
1398
1399 /** \brief Initialize biology tracers from whichever source
1400 * remora.biology_ic_type selects. Call after the physical fields
1401 * exist: the analytic profiles are functions of temperature. */
1402 void init_biology_ic (int lev);
1403
1404 /** \brief Full-domain counterpart of init_biology_ic, for the
1405 * hires_init_level average-down path. */
1407 /** \brief High resolution roblem initialization from NetCDF file */
1409 /** \brief Full-domain high-res biology initialization from NetCDF file */
1411 /** \brief Full-domain high-res passive (dye) scalar initialization from NetCDF file */
1413 /** \brief Boundary data initialization from NetCDF file */
1414 void init_bdry_from_netcdf (int lev);
1415 /** \brief Mask data initialization from NetCDF file */
1416 void init_masks_from_netcdf (int lev);
1417 /** \brief Full domain high-res mask data initialization from NetCDF file */
1419 /** \brief Bathymetry data initialization from NetCDF file */
1421 /** \brief Full domain high-res bathymetry data initialization from NetCDF file */
1423
1424 /** \brief Grid variable initialization from NetCDF file */
1426 /** \brief Full domain high-res grid variable initialization from NetCDF file */
1428
1429 /** \brief Extrapolate grid metrics to edge of MultiFab */
1430 void extrapolate_metric_to_physical_boundaries(amrex::MultiFab& mf, const amrex::Geometry& geom);
1431
1432 /** \brief Sea-surface height data initialization from NetCDF file */
1433 void init_zeta_from_netcdf (int lev);
1434 /** \brief Full-domain high res sea-surface height data initialization from NetCDF file */
1436 /** \brief Coriolis parameter data initialization from NetCDF file */
1437 void init_coriolis_from_netcdf (int lev);
1438 /** \brief Climatology nudging coefficient initialization from NetCDF file */
1440 /** \brief Wrapper to initialize climatology nudging coefficient */
1441 void init_clim_nudg_coeff (int lev);
1442 void init_riv_pos_from_netcdf (int lev);
1443
1444 /** \brief the DistributionMapping every full-domain multifab is built on.
1445 * Each of those covers the domain in a single box, so the map holds one entry, and which
1446 * rank it names is whichever holds the least fab memory when it is built. Building one per
1447 * allocator therefore put the mask and the data it weights on different ranks under MPI.
1448 * Empty until full_domain_dmap first needs it. **/
1449 amrex::DistributionMapping dm_full_domain;
1450
1451 /** \brief The shared full-domain DistributionMapping, built on first use */
1452 const amrex::DistributionMapping& full_domain_dmap ();
1453
1454 /** \brief Allocate multifabs for storing full-domain bathymetry and grid vars data */
1456 /** \brief Allocate multifabs for storing full-domain high resolution initial data */
1458
1459 /** \brief Convert data in a multifab from inverse days to inverse seconds */
1460 void convert_inv_days_to_inv_s (amrex::MultiFab*);
1461
1462 /** \brief Mask data arrays before writing output */
1463 void mask_arrays_for_write (int lev, amrex::Real fill_value, amrex::Real fill_where);
1464
1465 /** \brief Average down from level lev+1 to lev in mf, including grow cells */
1466 void average_down_with_grow_cells(int lev, amrex::Vector<std::unique_ptr<amrex::MultiFab>>& mf,
1467 bool use_mask = false);
1468
1469 /** \brief Average one field down a level, weighted by the land/sea mask. */
1470 /** \brief coarse cell mask, 1 where covered by lev+1, with one grow cell */
1471 void build_covered_mask (int crse_lev, amrex::MultiFab& covered);
1472
1473 /** \brief put back the coarse normal-velocity faces on the fine patch's perimeter */
1474 void restore_perimeter_faces (const amrex::MultiFab& saved, amrex::MultiFab& mf,
1475 const amrex::MultiFab& covered, int dir, int ncomp);
1476
1477 void average_down_masked (int crse_lev, const amrex::MultiFab& S_fine,
1478 amrex::MultiFab& S_crse, const amrex::MultiFab& msk_fine,
1479 const amrex::MultiFab& cmsk, int ncomp, int face_dir,
1480 bool volume_weighted = false);
1481
1482 /** \brief Initialize high-resolution initial data, zeta included, from analytic functions */
1484
1497
1498 ///@{
1499 /** \brief Accessors for the ncons-dependent entries of BdyVars */
1500 int bdy_cons (int icomp) const noexcept { return BdyVars::cons(icomp); }
1505 ///@}
1506
1507 /** \brief Number of passive (dye) scalars in the state, not counting biology tracers.
1508 *
1509 * Zero means the state has no dye component at all, so Tracer_comp is either the first
1510 * biology tracer or one past the end of cons. Problem setups that initialize a dye have
1511 * to test this rather than nComp(), which cannot tell a dye apart from a biology tracer.
1512 */
1514
1515
1516#ifdef REMORA_USE_NETCDF
1518#endif
1519
1520private:
1521
1522 ///////////////////////////
1523 // private member functions
1524 ///////////////////////////
1525
1526 /** \brief read in some parameters from inputs file */
1527 void ReadParameters();
1528
1529 /** \brief Build runtime scalar names after nscalar is known */
1530 void init_scalar_metadata();
1531
1532 /** \brief set covered coarse cells to be the average of overlying fine cells */
1533 void AverageDown ();
1534
1535 /** \brief Read in boundary parameters from input file and set up data structures */
1536 void init_bcs();
1537
1538 /** \brief Initialize initial problem data from analytic functions */
1539 void init_analytic(int lev);
1540 /** \brief Coordinate arrays of level lev, for the prob functions */
1541 ProbCoords prob_coords (int lev) const;
1542
1543 /** \brief Allocate MultiFabs for state and evolution variables */
1544 void init_stuff (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
1545
1546 /** \brief Allocate MultiFabs for masks */
1547 void init_masks (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
1548
1549 /** \brief Resize variable containers to accommodate data on levels 0 to max_lev */
1550 void resize_stuff (int lev);
1551
1552 /** \brief more flexible version of AverageDown() that lets you average down across multiple levels */
1553 void AverageDownTo (int crse_lev);
1554
1555 /** \brief Construct FillPatchers */
1557
1558 /** \brief Define FillPatchers */
1559 void Define_REMORAFillPatchers (int lev);
1560
1561 /** \brief utility to copy in data from old and/or new state into another multifab */
1562 TimeInterpolatedData GetDataAtTime (int lev, amrex::Real time);
1563
1564 /** \brief advance a level by dt, includes a recursive call for finer levels */
1565 void timeStep (int lev, amrex::Real time, int iteration);
1566
1567 /** \brief advance all levels by dt, loops over finer levels */
1568 void timeStepML (amrex::Real time, int iteration);
1569
1570 /** \brief a wrapper for estTimeStep() */
1571 void ComputeDt ();
1572
1573 /** \brief report the per-level slow/fast timestep hierarchy; call after ComputeDt */
1574 void print_timestep_hierarchy () const;
1575
1576 /** \brief size nsubsteps and set how many steps each level takes per parent step */
1577 void set_nsubsteps (int nlevs_max);
1578
1579 /** \brief get plotfile name */
1580 std::string PlotFileName (int lev) const;
1581
1582 /* set which variables and derived quantities go into plotfiles */
1583 void set2DPlotVariables (const std::string& pp_plot_var_names_2d);
1584 void set3DPlotVariables (const std::string& pp_plot_var_names_3d);
1585
1586 /* append variables to plot */
1587 void append2DPlotVariables (const std::string& pp_plot_var_names_2d);
1588 void append3DPlotVariables (const std::string& pp_plot_var_names_3d);
1589
1590#ifdef REMORA_USE_NETCDF
1591 /** \brief Write plotfile using NetCDF (wrapper) */
1592 void WriteNCPlotFile (int istep, amrex::MultiFab const* plotMF, int lev = 0,
1593 amrex::MultiFab const* mf_omega = nullptr,
1594 amrex::MultiFab const* mf_wvel = nullptr);
1595
1596 /** \brief Write a particular NetCDF plotfile */
1598 amrex::MultiFab const* plotMF,
1599 amrex::MultiFab const* mf_omega,
1600 amrex::MultiFab const* mf_wvel,
1602 bool is_history, long long history_record = 0);
1603
1604 /** \brief Record at which a restarted run continues a history file */
1605 long long history_restart_record (int lev, const std::string& path);
1606
1607 /** \brief Write MultiFab in NetCDF format */
1608 void WriteNCMultiFab (const amrex::FabArray<amrex::FArrayBox> &fab,
1609 const std::string& name,
1610 bool set_ghost = false) const;
1611
1612 /** \brief Read MultiFab in NetCDF format */
1613 void ReadNCMultiFab (amrex::FabArray<amrex::FArrayBox> &fab,
1614 const std::string &name,
1615 int coordinatorProc = amrex::ParallelDescriptor::IOProcessorNumber(),
1616 int allow_empty_mf = 0);
1617
1618 /** \brief Whether to output NetCDF files as a single history file with several time steps */
1620
1621 /** \brief Data container for u-component surface momentum flux read from file */
1622 std::unique_ptr<NCTimeSeries> sustr_data_from_file;
1623 /** \brief Data container for v-component surface momentum flux read from file */
1624 std::unique_ptr<NCTimeSeries> svstr_data_from_file;
1625 /** \brief Data container for u-direction wind read from file */
1626 std::unique_ptr<NCTimeSeries> Uwind_data_from_file;
1627 /** \brief Data container for v-direction wind read from file */
1628 std::unique_ptr<NCTimeSeries> Vwind_data_from_file;
1629 /** \brief Data container for air temperature read from file */
1630 std::unique_ptr<NCTimeSeries> Tair_data_from_file;
1631 /** \brief Data container for specific humidity read from file */
1632 std::unique_ptr<NCTimeSeries> qair_data_from_file;
1633 /** \brief Data container for air pressure read from file */
1634 std::unique_ptr<NCTimeSeries> Pair_data_from_file;
1635 /** \brief Data container for shortwave radiation flux read from file */
1636 std::unique_ptr<NCTimeSeries> srflx_data_from_file;
1637 /** \brief Data container for downward longwave radiation flux read from file */
1638 std::unique_ptr<NCTimeSeries> longwave_down_data_from_file;
1639 /** \brief Data container for precipitation rate read from file */
1640 std::unique_ptr<NCTimeSeries> rain_data_from_file;
1641 /** \brief Data container for cloud cover fraction read from file */
1642 std::unique_ptr<NCTimeSeries> cloud_data_from_file;
1643 /** \brief Data container for evaporation minus precipitation read from file */
1644 std::unique_ptr<NCTimeSeries> EminusP_data_from_file;
1645
1646 /** \brief Data container for ubar climatology data read from file */
1647 std::unique_ptr<NCTimeSeries> ubar_clim_data_from_file;
1648 /** \brief Data container for vbar climatology data read from file */
1649 std::unique_ptr<NCTimeSeries> vbar_clim_data_from_file;
1650 /** \brief Data container for u-velocity climatology data read from file */
1651 std::unique_ptr<NCTimeSeries> u_clim_data_from_file;
1652 /** \brief Data container for v-velocity climatology data read from file */
1653 std::unique_ptr<NCTimeSeries> v_clim_data_from_file;
1654 /** \brief Vector over cons components of climatology data read from file.
1655 *
1656 * Entry icomp is null unless solverChoice.do_cons_clim_nudg[icomp] is set. */
1657 amrex::Vector<std::unique_ptr<NCTimeSeries>> cons_clim_data_from_file;
1658
1659 /** \brief Vector of data containers for scalar data in rivers */
1660 amrex::Vector<std::unique_ptr<NCTimeSeriesRiver>> river_source_cons;
1661 /** \brief Data container for momentum transport in rivers */
1662 std::unique_ptr<NCTimeSeriesRiver> river_source_transport;
1663 /** \brief Data container for vertically integrated momentum transport in rivers */
1664 std::unique_ptr<NCTimeSeriesRiver> river_source_transportbar;
1665
1666 /** \brief Vector over BdyVars of boundary series data containers */
1667 amrex::Vector<amrex::Vector<std::unique_ptr<NCTimeSeriesBoundary>>> boundary_series;
1668
1669#endif // REMORA_USE_NETCDF
1670 /** \brief iMultiFab for river positions; contents are indices of rivers */
1671 amrex::Vector<std::unique_ptr<amrex::iMultiFab>> vec_river_position;
1672 /** \brief Vector over rivers of river direction: 0: u-face; 1: v-face; 2: w-face */
1673 amrex::Gpu::DeviceVector<int> river_direction;
1674
1675
1676#ifdef REMORA_USE_MOAB
1677 /** \brief Initialize connection to MOAB */
1678 void InitMOABMesh();
1679#endif
1680 /** \brief Nudging width at coarse-fine interface */
1681 int cf_width{0};
1682 /** \brief Width for fixing values at coarse-fine interface */
1684 // Fillpatcher classes for coarse-fine boundaries
1685 /** \brief Vector over levels of FillPatchers for scalars */
1686 amrex::Vector<REMORAFillPatcher> FPr_c;
1687 /** \brief Vector over levels of FillPatchers for u (3D) */
1688 amrex::Vector<REMORAFillPatcher> FPr_u;
1689 /** \brief Vector over levels of FillPatchers for v (3D) */
1690 amrex::Vector<REMORAFillPatcher> FPr_v;
1691 /** \brief Vector over levels of FillPatchers for w */
1692 amrex::Vector<REMORAFillPatcher> FPr_w;
1693
1694 // Fillpatcher classes for 2d velocity variables
1695 /** \brief Vector over levels of FillPatchers for ubar (2D) */
1696 amrex::Vector<REMORAFillPatcher> FPr_ubar;
1697 /** \brief Vector over levels of FillPatchers for vbar (2D) */
1698 amrex::Vector<REMORAFillPatcher> FPr_vbar;
1699 /** \brief Vector over levels of FillPatchers for Dubar (2D) */
1700 amrex::Vector<REMORAFillPatcher> FPr_Dubar;
1701 /** \brief Vector over levels of FillPatchers for Dvbar (2D) */
1702 amrex::Vector<REMORAFillPatcher> FPr_Dvbar;
1703
1704 /** \brief write checkpoint file to disk */
1705 void WriteCheckpointFile ();
1706
1707 /** \brief read checkpoint file from disk */
1708 void ReadCheckpointFile ();
1709
1710 /** \brief Read the file passed to remora.restart and use it as an initial condition for the current simulation */
1712
1713 /** \brief Initialize the new-time data at a level from the initial_data MultiFab */
1714 void InitializeLevelFromData (int lev, const amrex::MultiFab& initial_data);
1715
1716 /** \brief utility to skip to next line in Header */
1717 static void GotoNextLine (std::istream& is);
1718
1719 ////////////////
1720 // private data members
1721
1722 /** \brief Pointer to container of analytical functions for problem definition */
1723 std::unique_ptr<ProblemBase> prob = nullptr;
1724
1725 /** \brief how many boxes specified at each level by tagging criteria */
1726 amrex::Vector<int> num_boxes_at_level;
1727 /** \brief how many netcdf input files specified at each level */
1728 amrex::Vector<int> num_files_at_level;
1729 /** \brief the boxes specified at each level by tagging criteria */
1730 amrex::Vector<amrex::Vector<amrex::Box>> boxes_at_level;
1731
1732 /** \brief which step? */
1733 amrex::Vector<int> istep;
1734 /** \brief How many substeps on each level? */
1735 amrex::Vector<int> nsubsteps;
1736 /** \brief new time at each level, in seconds since start_time
1737 *
1738 * Model time is split into a double start_time and a Real elapsed time, as ROMS
1739 * splits DSTART from the time it advances. The solver, the FillPatch time
1740 * interpolation, and the kernels only ever see elapsed time, which stays small
1741 * enough for a float to resolve a timestep. Anything that needs a time on the
1742 * model clock -- forcing and boundary files, the calendar, output time stamps,
1743 * user-given times -- goes through model_time() in double. */
1744 amrex::Vector<amrex::Real> t_new;
1745 /** \brief old time at each level, in seconds since start_time */
1746 amrex::Vector<amrex::Real> t_old;
1747 /** \brief time step at each level */
1748 amrex::Vector<amrex::Real> dt;
1749
1750 /** \brief whether to set boundary conditions by variable rather than just by side */
1752
1753 /** \brief Vector (over level) of functors to apply physical boundary conditions */
1754 amrex::Vector<std::unique_ptr<REMORAPhysBCFunct>> physbcs;
1755
1756 /** \brief array of flux registers for refluxing in multilevel */
1757 amrex::Vector<std::unique_ptr<amrex::YAFluxRegister>> advflux_reg;
1758
1759 /** \brief flux register between lev and lev-1 */
1760 amrex::YAFluxRegister* getAdvFluxReg (int lev) { return advflux_reg[lev].get(); }
1761
1762 /** \brief build or rebuild the flux register between lev and lev-1 */
1763 void define_flux_register (int lev);
1764
1765 ////////////////
1766 // boundary data members
1767
1768 // A BCRec is essentially a 2*DIM integer array storing the boundary
1769 // condition type at each lo/hi walls in each direction. We have one BCRec
1770 // for each component of the cell-centered variables and each velocity component.
1771 /** \brief vector (over BCVars) of BCRecs */
1772 amrex::Vector <amrex::BCRec> domain_bcs_type;
1773 /** \brief GPU vector (over BCVars) of BCRecs */
1774 amrex::Gpu::DeviceVector<amrex::BCRec> domain_bcs_type_d;
1775
1776 /** \brief Array of strings describing domain boundary conditions */
1777 amrex::Array<std::string,2*AMREX_SPACEDIM> domain_bc_type;
1778
1779 /** \brief Array holding the Dirichlet values at walls which need them */
1780 amrex::Vector<amrex::GpuArray<amrex::Real, AMREX_SPACEDIM*2>> m_bc_extdir_vals;
1781
1782 /** \brief Array holding the "physical" boundary condition types (e.g. "inflow") */
1783 amrex::Vector<amrex::GpuArray<REMORA_BC, AMREX_SPACEDIM*2>> phys_bc_type;
1784
1785 /** \brief These are flags that indicate whether we need to read in boundary data from file.
1786 *
1787 * Sized num_bdy_vars()+1; the extra trailing slot is a scratch entry that variables with
1788 * no NetCDF boundary lane (see bdy_index) write into and nothing reads.
1789 */
1790 amrex::Vector<amrex::GpuArray<bool, AMREX_SPACEDIM*2>> phys_bc_need_data;
1791
1792 /** \brief Container to connect boundary data being read in boundary condition containers.
1793 *
1794 * Needed for phys_bc_need_data to work correctly
1795 */
1796 amrex::Vector<int> bdy_index;
1797
1798 /** \brief Step when we last output a plotfile */
1800 /** \brief Simulation time when we last output a plotfile */
1802
1803 /** \brief Step when we last output a checkpoint file */
1805 /** \brief Simulation time when we last output a checkpoint file */
1807 /** \brief Whether to output a plotfile on restart from checkpoint */
1809
1810 ////////////////
1811 // runtime parameters
1812
1813 /** \brief maximum number of steps */
1814 int max_step = std::numeric_limits<int>::max();
1815 /** \brief Time to stop, in seconds on the model clock (not since start_time) */
1816 double stop_time = std::numeric_limits<amrex::Real>::max();
1817
1818 /** \brief Time of the start of the simulation, in seconds on the model clock.
1819 *
1820 * Also the origin of t_new and t_old. Double regardless of Real: seconds since a
1821 * calendar epoch outgrow a float's resolution within days. */
1822 double start_time = 0.0;
1823
1824 /** \brief If set, restart from this checkpoint file */
1825 std::string restart_chkfile = "";
1826
1827 /** \brief Number of passive (dye) scalars carried in the state, beyond temperature
1828 * and salinity. Does not count biology tracers. Dye is opt-in: a run
1829 * carries one only when remora.nscalar asks for it. */
1830 int nscalar = 0;
1831 /** \brief Number of biology tracers, set by the active biology model. Zero when no
1832 * biology model is active. */
1833 int nbio = 0;
1834 /** \brief First cons component of the biology block, i.e. Tracer_comp + nscalar.
1835 * The state is laid out as temp, salt, the passive scalars, then biology. */
1837 /** \brief Number of conserved scalars in the state
1838 * (temperature + salt + passive scalars + biology tracers) */
1840 /** \brief Active biology package */
1842 /** \brief Runtime parameters for the Fennel biology package */
1844 /** \brief Source of the biology tracer initial condition, independent of
1845 * remora.ic_type. Default follows ic_type. */
1847 /** \brief Select the native C++ biology kernel (1) or the ROMS Fortran
1848 * bridge oracle (0). Only meaningful when built with
1849 * USE_FENNEL_FORT=TRUE; ignored otherwise. Runtime-controlled so
1850 * the two paths can be compared without a rebuild. */
1852 /** \brief Biology diagnostic verbosity: 0 off, 1 target column, 2 all
1853 * columns. See Source/Biology/Fortran/tag_map.md. */
1855 /** \brief Target column i index for biology_debug = 1 */
1857 /** \brief Target column j index for biology_debug = 1 */
1859
1860 // Time step controls
1861 /** \brief CFL condition */
1862 static amrex::Real cfl;
1863 /** \brief Fraction maximum change in subsequent time steps */
1864 static amrex::Real change_max;
1865 /** \brief User specified fixed baroclinic time step */
1866 static amrex::Real fixed_dt;
1867 /** \brief User specified, number of barotropic steps per baroclinic step */
1868 static int ndtfast;
1869 /** \brief Number of fast steps to take */
1871
1872 /** \brief Whether to substep fine levels in time */
1873 int do_substep = 1;
1874
1875 /** \brief interpolate the parent's barotropic mass flux in time at the coarse-fine
1876 * interface, rather than holding its step average. Off matches most ROMS
1877 * configurations. */
1878 bool time_interp_flux = false;
1879
1880 /** \brief impose the parent's barotropic mass flux on DUon/DVom at the coarse-fine
1881 * interface, rather than relying on the velocity written by set_2d_cf_bcs being
1882 * turned back into the same flux. Off by default: it improves conservation but
1883 * does not cure the two-level barotropic instability seen in Channel_Test. */
1885
1886 /** \brief correct the coarse tracer with the finer level's accumulated advective flux
1887 * at their interface. Only has an effect under remora.do_substep with two-way
1888 * coupling. */
1889 int do_reflux = 1;
1890
1891 /** \brief exclude the coarse-fine perimeter's normal-velocity faces from the fine-to-coarse
1892 * average, as ROMS does. 1 (default) matches ROMS; 0 includes the perimeter faces
1893 * in the average. */
1895
1896 /** \brief re-fill the child's 3D velocity from the parent after the step, so the coarse-fine
1897 * boundary carries the parent's shear profile rather than the one vert_mean_3d left
1898 * there. Diagnostic; off, so it changes no answer unless set. Both drivers do it
1899 * only under this knob -- see the comment in Advance. On the ratio-3 Dogbone it
1900 * moves level-1 x-velocity by 4.1e-3 relative and level 0 by 1.9e-4 after 20
1901 * steps. */
1903 /** \brief 0 = never impose the 2D coarse-fine interface condition, 1 = every fast step,
1904 * 2 = only the first fast step of each baroclinic step.
1905 *
1906 * 1 matches ROMS and is the default: put_refine2d runs once before the barotropic loop,
1907 * but u2dbc_im re-applies the same mass-flux formula on every fast step inside it, so 2
1908 * is only half the ROMS schedule. On the dogbone, 2 helps early and is much worse
1909 * later. */
1912 /** \brief write every leapfrog record of the coarse-fine ghost band, as put_refine2d does
1913 * when it sets zeta(:,:,1:3) and Zt_avg1 to one value; without it those records go
1914 * a whole parent step stale. On by default. Roundoff on the ROMS-matched deck,
1915 * where the fine zeta halo is barely read, but the dominant cost to volume
1916 * conservation on the subcycled dogbone: 2.0e-09 to 2.9e-08 of drift over 20
1917 * steps, volume being the integral of the free surface this writes. ROMS makes
1918 * the same trade. */
1920 /** \brief interpolate the parent in time onto the child's own sub-time, as put_refine2d
1921 * does, rather than freezing it at the end of the parent step. On by default, and
1922 * non-conservative for the same reason as cf_fill_all_kcomp: 1.4e-08 of volume
1923 * drift on its own. */
1925 /** \brief distribute the parent's interface mass flux piecewise-constantly over the fine
1926 * faces under each parent face, as ROMS's get_persisted2d does, instead of with
1927 * the linear tangential variation of AMReX's face interpolator. Both conserve the
1928 * total; they differ in the profile along the interface. On by default: it removes
1929 * the fine level's own excess divergence there. */
1930 int cf_flux_pc = 1;
1931 /** \brief average the fine velocity onto the coarse over ROMS's nine-point stencil
1932 * (fine2coarse2d, half-width (Rscale-1)/2 in both directions) instead of only the
1933 * faces that tile the coarse face. On by default: with cf_flux_pc it takes the
1934 * interface refinement perturbation from 1.29x ROMS's to 1.01x on the matched
1935 * dogbone, the residual 1% closing only with cf_impose_flux, which stays off. Not
1936 * conservative in principle -- the nine-point mean does not preserve transport
1937 * across the interface -- but only about 3e-10 of volume drift in practice, well
1938 * under the free-surface ghost band's cost. */
1940 /** \brief average the fine tracers onto the coarse weighted by cell volume, Hz/(pm*pn),
1941 * rather than by area as ROMS's fine2coarse3d does. Off by default. Where the
1942 * fine layer thickness varies under a coarse cell, as interpolated bathymetry
1943 * near land makes it, the area mean gains or loses tracer content. Volume
1944 * weighting keeps it only where the coarse cell's volume matches the fine
1945 * volumes under it, so not at a coast, and it is not applied to the initial
1946 * high-resolution cascade (average_down_with_grow_cells). */
1948
1949 /** \brief print the imposed coarse-fine interface velocity at this baroclinic step
1950 * (-1 = off). Diagnostic only; the fine level is not in the NetCDF output. */
1952
1953 /** \brief stop that correction driving a tracer negative, as ROMS does. On by default to
1954 * match ROMS; costs exact conservation on any step that clamps. */
1956
1957 /** \brief measure whether fine cell edges tile the coarse ones at a coarse-fine
1958 * interface, which is what makes the imposed mass flux conservative */
1960 /** \brief tolerance for the above */
1961 amrex::Real check_cf_tol = 1.e-12;
1962
1963 /** \brief check the nodal z a viewer rebuilds from the plotfile's Nu_nd set against
1964 * z_phys_nd on each level, and fine against coarse at coincident nodes */
1966 /** \brief abort when the coarse-fine mismatch at interior nodes exceeds this; negative
1967 * (the default) only reports it, since where a finer level carries finer
1968 * bathymetry the two levels' bottoms legitimately differ */
1969 amrex::Real check_plot_z_tol = -1.0;
1970
1971 /** \brief how often each level regrids the higher levels of refinement (after a level advances that many time steps) */
1972 int regrid_int = 2;
1973
1974 // I/O controls
1975 /** \brief Plotfile prefix */
1976 std::string plot_file_name {"plt_"};
1977 /** \brief Plotfile output interval in iterations */
1978 int plot_int = -1;
1979 /** \brief Plotfile output interval in seconds */
1980 amrex::Real plot_int_time = amrex::Real(-one);
1981 /** \brief Checkpoint file prefix */
1982 std::string check_file {"chk"};
1983 /** \brief Checkpoint output interval in iterations */
1984 int check_int = -1;
1985 /** \brief Checkpoint output interval in seconds */
1986 amrex::Real check_int_time = amrex::Real(-one);
1987
1988 /** \brief Whether to split the netcdf history file into fixed-length chunks */
1990 /** \brief Time steps per netcdf history file. Must be > 0 if chunk_history_file. */
1992 /** \brief Counter for which time index we are writing to in the netcdf history file */
1994 /** \brief Per level, the history file this run last wrote to */
1995 amrex::Vector<std::string> history_file_in_use;
1996 /** \brief Per level, history_count minus the record written in the file in
1997 * use. Nonzero only after a restart. */
1998 amrex::Vector<long long> history_record_shift;
1999
2000 /** \brief Names of 3D variables to output to AMReX plotfile */
2001 amrex::Vector<std::string> plot_var_names_3d;
2002 /** \brief Names of 2D variables to output to AMReX plotfile */
2003 amrex::Vector<std::string> plot_var_names_2d;
2004 /** \brief Whether to write omega, the S-coordinate vertical velocity, to NetCDF output */
2005 bool plot_omega = false;
2006 /** \brief Whether to write z_velocity, the true vertical velocity, to NetCDF output as w */
2007 bool plot_wvel = false;
2008 /** \brief Names of scalars for plotfile output */
2009 amrex::Vector<std::string> cons_names {"temp", "salt", "tracer"};
2010 // Note that the order of variable names here must match the order in PlotFile.cpp
2011 /** \brief Names of derived fields for 3d plotfile fields */
2012 const amrex::Vector<std::string> derived_names_3d {"vorticity", "omega"};
2013 /** \brief Names of derived fields for 2d plotfile fields */
2014 const amrex::Vector<std::string> derived_names_2d {};
2015
2016 /** \brief Container for algorithmic choices */
2018
2019 /** \brief whether plotfile variables should be expanded to a uniform refinement ratio */
2021
2022 /** \brief fill value for masked arrays in amrex plotfiles */
2024 /** \brief fill value for masked arrays in netcdf output */
2025 amrex::Real netcdf_fill_value = amrex::Real(1.0e37);
2026
2027
2028#ifdef REMORA_USE_PARTICLES
2029 /** \brief Particle container with all particle species */
2031
2032 // variables and functions for tracers particles
2033 /** \brief tracer particles that advect with flow */
2035 /** \brief tracer particles that fall with gravity */
2037
2038 /** \brief Read tracer and hydro particles parameters */
2039 void readTracersParams();
2040
2041 /** \brief Initialize tracer and hydro particles */
2042 void initializeTracers ( amrex::ParGDBBase*,
2043 const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
2044
2045 /** \brief Evolve tracers and hydro particles */
2046 void evolveTracers( int lev,
2047 amrex::Real dt,
2048 amrex::Vector<amrex::MultiFab const*>& flow_vel,
2049 const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
2050
2051#endif
2052 /** \brief Verbosity level of output */
2053 static int verbose;
2054
2055 /** \brief Diagnostic sum output interval in number of steps */
2056 static int sum_interval;
2057 /** \brief Diagnostic sum output interval in time */
2058 static amrex::Real sum_per;
2059
2060 /** \brief Minimum number of digits in plotfile name or chunked history file */
2062
2063 /** \brief Whether to write the staggered velocities (not averaged to cell centers) */
2065
2066 /** \brief Whether to write nodal data (Nu_nd) to plotfiles */
2067 static bool plot_nodal_data;
2068
2069 /** \brief Native or NetCDF plotfile output */
2071
2072 /** \brief NetCDF initialization file */
2073 static amrex::Vector<amrex::Vector<std::string>> nc_init_file;
2074 /** \brief NetCDF grid file */
2075 static amrex::Vector<amrex::Vector<std::string>> nc_grid_file;
2076 /** \brief NetCDF boundary data */
2077 static amrex::Vector<std::string> nc_bdry_file;
2078
2079 /** \brief Which level the high resolution bathymetry is at */
2081 /** \brief Grid file for high resolution bathymetry */
2083 /** \brief Box for the full domain at nc_hires_grid_level */
2085
2086 /** \brief Which level the high resolution initialization data is at */
2088 /** \brief Init file for high resolution */
2090 /** \brief Box for the full domain at nc_hires_init_level */
2092
2093 /** \brief Cumulative refinement ratio between level 0 and level i */
2094 amrex::Vector<amrex::IntVect> cum_ref_ratios;
2095
2096 /** \brief NetCDF forcing file(s) */
2097 amrex::Vector<std::string> nc_frc_file;
2098 /** \brief NetCDF river file(s) */
2099 amrex::Vector<std::string> nc_riv_file;
2100
2101 /** \brief NetCDF climatology history file(s) */
2102 amrex::Vector<std::string> nc_clim_his_file;
2103 /** \brief NetCDF climatology coefficient file */
2105
2106 /** \brief Default name of time field for boundary data */
2107 std::string bdry_time_varname = "ocean_time";
2108 /** \brief Name of time fields for boundary data */
2109 amrex::Vector<std::string> bdry_time_name_byvar;
2110
2111 /** \brief Name of time field for ubar climatology data */
2112 std::string clim_ubar_time_varname = "ocean_time";
2113 /** \brief Name of time field for vbar climatology data */
2114 std::string clim_vbar_time_varname = "ocean_time";
2115 /** \brief Name of time field for u climatology data */
2116 std::string clim_u_time_varname = "ocean_time";
2117 /** \brief Name of time field for v climatology data */
2118 std::string clim_v_time_varname = "ocean_time";
2119 /** \brief Vector over cons components of the name of the time field for that
2120 * tracer's climatology data */
2121 amrex::Vector<std::string> clim_cons_time_varname;
2122 /** \brief Name of time field for river time */
2123 std::string riv_time_varname = "river_time";
2124 /** \brief Name of time field for forcing data */
2125 std::string frc_time_varname = "";
2126
2127 /** \brief Set refinement criteria */
2129
2130 /** \brief Reject vertical refinement and accumulate the refinement ratios */
2131 void init_ref_ratios ();
2132
2133 /** \brief Holds info for dynamically generated tagging criteria */
2134 static amrex::Vector<REMORAErrorTag> ref_tags;
2135
2136 /** \brief Mask that zeroes out values on a coarse level underlying grids on the next finest level */
2137 amrex::MultiFab fine_mask;
2138
2139 /** \brief Helper function for IO stream */
2141 std::ostream&
2143 {
2144 return *datalog[i];
2145 }
2146
2148 int
2150 {
2151 return datalog.size();
2152 }
2153
2154 /** \brief Variable for CPU timing */
2155 static amrex::Real startCPUTime;
2156 /** \brief Accumulator variable for CPU time used thusfar */
2157 static amrex::Real previousCPUTimeUsed;
2158
2159 /** \brief Get CPU time used */
2160 amrex::Real
2162 {
2163 int numCores = amrex::ParallelDescriptor::NProcs();
2164#ifdef _OPENMP
2166#endif
2167
2168 amrex::Real T =
2169 numCores * (amrex::Real(amrex::ParallelDescriptor::second()) - startCPUTime) +
2171
2172 return T;
2173 }
2174
2175 void setRecordDataInfo (int i, const std::string& filename)
2176 {
2177 if (amrex::ParallelDescriptor::IOProcessor())
2178 {
2179 datalog[i] = std::make_unique<std::fstream>();
2180 datalog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
2181 if (!datalog[i]->good()) {
2182 amrex::FileOpenFailed(filename);
2183 }
2184 }
2185 amrex::ParallelDescriptor::Barrier("REMORA::setRecordDataInfo");
2186 }
2187
2188 amrex::Vector<std::unique_ptr<std::fstream> > datalog;
2189 amrex::Vector<std::string> datalogname;
2190
2191 /** \brief The filename of the ith datalog file. */
2192 const std::string DataLogName (int i) const noexcept { return datalogname[i]; }
2193
2194public:
2195 /** \brief Write job info to stdout */
2196 void writeJobInfo (const std::string& dir) const;
2197 /** \brief Write build info to os */
2198 static void writeBuildInfo (std::ostream& os);
2199
2200 static void print_banner(MPI_Comm /*comm*/, std::ostream& /*out*/);
2201 static void print_usage(MPI_Comm /*comm*/, std::ostream& /*out*/);
2202 static void print_error(MPI_Comm /*comm*/, const std::string& msg);
2203 static void print_summary(std::ostream&);
2204 static void print_tpls(std::ostream& /*out*/);
2205
2206 /** \brief Accessor method for t_old to expose to outside classes */
2207 amrex::Real get_t_old(int lev) const;
2208
2209 /** \brief Time on the model clock, in seconds, of an elapsed time such as t_new */
2210 double model_time (amrex::Real elapsed) const noexcept
2211 {
2212 return start_time + static_cast<double>(elapsed);
2213 }
2214
2215 /** \brief Elapsed time since start_time of a time on the model clock */
2216 amrex::Real elapsed_time (double time) const noexcept
2217 {
2218 return static_cast<amrex::Real>(time - start_time);
2219 }
2220
2221 /** \brief First cons component of the biology block. Problem setups need this to
2222 * write biology initial conditions, since the passive scalars sit between
2223 * salinity and the biology tracers. */
2225 /** \brief Number of biology tracers carried in the state */
2226 int num_bio () const noexcept { return nbio; }
2227 /** \brief Number of passive (dye) scalars carried in the state */
2229
2230 /** \brief Evaluate stability function psi for wind speed */
2232 static amrex::Real bulk_psiu(amrex::Real ZoL) {
2233 // Compute stability function, psi
2234 using namespace amrex;
2235
2236 Real psiu;
2237 if (ZoL < zero) {
2238 // Unstable conditions.
2239 Real x = std::pow(one-Real(15.0)*ZoL,fourth);
2240 Real psik = two*std::log(Real(0.5)*(one+x))+
2241 std::log(Real(0.5)*(one+x*x))-
2242 two*std::atan(x)+Real(0.5)*PI;
2243 // For very unstable conditions, use free-convection (Fairall).
2244 Real sqrt3 = std::sqrt(three);
2245 Real y = std::pow(one-Real(10.15)*ZoL,third);
2246 Real psic = Real(1.5)*std::log(one/Real(three)*(one+y+y*y))-
2247 sqrt3*std::atan((one+two*y)/sqrt3)+PI/sqrt3;
2248 // Match Kansas and free-convection forms with weighting Fw.
2249 Real Zol2 = ZoL*ZoL;
2250 Real Fw = Zol2/(one+Zol2);
2251
2252 psiu = (one-Fw)*psik+Fw*psic;
2253 } else {
2254 // Stable conditions
2255 Real cff=std::min(Real(50.0),Real(0.35)*ZoL);
2256 psiu = -((one+ZoL)+Real(0.6667)*(ZoL-Real(14.28))/
2257 std::exp(cff)+Real(8.525));
2258 }
2259 return psiu;
2260 }
2261
2262 /** \brief Evaluate stability function psi for moisture and heat */
2264 static amrex::Real bulk_psit(amrex::Real ZoL) {
2265 // Compute stability function, psi
2266 using namespace amrex;
2267
2268 Real psit;
2269 if (ZoL < zero) {
2270 // Unstable conditions.
2271 Real x = std::pow(one-Real(15.0)*ZoL,Real(0.5));
2272 Real psik = two*std::log(Real(0.5)*(one+x));
2273 // For very unstable conditions, use free-convection (Fairall).
2274 Real sqrt3=std::sqrt(three);
2275 Real y=std::pow(one-Real(34.15)*ZoL,one/three);
2276 Real psic=Real(1.5)*std::log(one/three*(one+y+y*y))-
2277 sqrt3*std::atan((one+two*y)/sqrt3)+PI/sqrt3;
2278
2279 // Match Kansas and free-convection forms with weighting Fw.
2280 Real ZoL2=ZoL*ZoL;
2281 Real Fw=ZoL2/(one+ZoL2);
2282 psit = (one-Fw)*psik+Fw*psic;
2283 } else {
2284 // Stable conditions.
2285 Real cff=std::min(Real(50.0),Real(0.35)*ZoL);
2286 psit=-(std::pow(one+two*ZoL,Real(1.5))+
2287 Real(0.6667)*(ZoL-Real(14.28))/std::exp(cff)+Real(8.525));
2288 }
2289 return psit;
2290 }
2291};
2292
2293#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:2070
std::string nc_grid_file_hires
Grid file for high resolution bathymetry.
Definition REMORA.H:2082
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:2099
void set_grid_vars_averaged_down(int lev)
Set pm/pn by averaging down from higher-resolution grid.
Definition REMORA.cpp:828
std::string riv_time_varname
Name of time field for river time.
Definition REMORA.H:2123
int foextrap_periodic_bc() const noexcept
Definition REMORA.H:1492
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:1870
amrex::Vector< std::string > nc_clim_his_file
NetCDF climatology history file(s)
Definition REMORA.H:2102
int ncons
Number of conserved scalars in the state (temperature + salt + passive scalars + biology tracers)
Definition REMORA.H:1839
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
Time to stop, in seconds on the model clock (not since start_time)
Definition REMORA.H:1816
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:2089
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:1856
static amrex::Real fixed_dt
User specified fixed baroclinic time step.
Definition REMORA.H:1866
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:1801
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:1487
static bool plot_staggered_vels
Whether to write the staggered velocities (not averaged to cell centers)
Definition REMORA.H:2064
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:1485
amrex::Vector< amrex::BCRec > domain_bcs_type
vector (over BCVars) of BCRecs
Definition REMORA.H:1772
bool set_bcs_by_var
whether to set boundary conditions by variable rather than just by side
Definition REMORA.H:1751
void set_zeta_averaged_down(int lev)
Copy over zeta data that has been averaged down from high res.
Definition REMORA.cpp:902
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:1632
static amrex::Real previousCPUTimeUsed
Accumulator variable for CPU time used thusfar.
Definition REMORA.H:2157
amrex::Vector< std::string > cons_names
Names of scalars for plotfile output.
Definition REMORA.H:2009
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:1757
std::unique_ptr< NCTimeSeries > sustr_data_from_file
Data container for u-component surface momentum flux read from file.
Definition REMORA.H:1622
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:1951
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:1878
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:2137
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:1690
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)
void compute_omega_and_w(int lev, amrex::MultiFab *mf_omega, amrex::MultiFab *mf_wvel)
omega and w on the s_w points of the NetCDF output, ghost columns filled and masked
void WriteNCPlotFile(int istep, amrex::MultiFab const *plotMF, int lev=0, amrex::MultiFab const *mf_omega=nullptr, amrex::MultiFab const *mf_wvel=nullptr)
Write plotfile using NetCDF (wrapper)
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:1619
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:1491
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:1640
void define_flux_register(int lev)
build or rebuild the flux register between lev and lev-1
Definition REMORA.cpp:2799
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:1841
bool plot_omega
Whether to write omega, the S-coordinate vertical velocity, to NetCDF output.
Definition REMORA.H:2005
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vwind
Wind in the v direction, defined at rho-points.
Definition REMORA.H:486
bool m_use_hydro_particles
tracer particles that fall with gravity
Definition REMORA.H:2036
std::unique_ptr< ProblemBase > prob
Pointer to container of analytical functions for problem definition.
Definition REMORA.H:1723
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:1154
void initializeTracers(amrex::ParGDBBase *, const amrex::Vector< std::unique_ptr< amrex::MultiFab > > &)
Initialize tracer and hydro particles.
void Construct_REMORAFillPatchers(int lev)
Construct FillPatchers.
Definition REMORA.cpp:586
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:2056
int history_count
Counter for which time index we are writing to in the netcdf history file.
Definition REMORA.H:1993
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rain
precipitation rate [kg/m^2/s]
Definition REMORA.H:515
void compute_diagnostic_omega(int lev, amrex::MultiFab &mf_omega)
omega (m/s) as ROMS writes it: from mass fluxes of the current velocities
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:1873
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:272
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:2107
amrex::Real plotfile_fill_value
fill value for masked arrays in amrex plotfiles
Definition REMORA.H:2023
int num_passive_scalars() const noexcept
Number of passive (dye) scalars in the state, not counting biology tracers.
Definition REMORA.H:1513
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:1854
bool chunk_history_file
Whether to split the netcdf history file into fixed-length chunks.
Definition REMORA.H:1989
void WriteNCPlotFile_which(int lev, int which_subdomain, amrex::MultiFab const *plotMF, amrex::MultiFab const *mf_omega, amrex::MultiFab const *mf_wvel, bool write_header, ncutils::NCFile &ncf, bool is_history, long long history_record=0)
Write a particular NetCDF plotfile.
void writeJobInfo(const std::string &dir) const
Write job info to stdout.
int num_bc_vars() const noexcept
Definition REMORA.H:1496
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:3425
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:1486
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:3086
std::unique_ptr< NCTimeSeries > longwave_down_data_from_file
Data container for downward longwave radiation flux read from file.
Definition REMORA.H:1638
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:2189
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:391
void set_massflux_3d(int lev, amrex::MultiFab &mf_Huon, amrex::MultiFab &mf_Hvom)
Horizontal mass fluxes Hz*u/n and Hz*v/m of the current velocities, as ROMS set_massflux.
void set_surface_state(int lev)
Initialize or calculate wind speed and other surface state vars from file or analytic.
Definition REMORA.cpp:1728
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:2714
int num_scalar() const noexcept
Number of passive (dye) scalars carried in the state.
Definition REMORA.H:2228
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:361
double start_time
Time of the start of the simulation, in seconds on the model clock.
Definition REMORA.H:1822
void init_only(int lev, amrex::Real time)
Init (NOT restart or regrid)
Definition REMORA.cpp:1857
void init_set_vmix(int lev)
Initialize vertical mixing coefficients from file or analytic.
Definition REMORA.cpp:959
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)
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, bool volume_weighted=false)
Definition REMORA.cpp:3159
std::unique_ptr< NCTimeSeries > v_clim_data_from_file
Data container for v-velocity climatology data read from file.
Definition REMORA.H:1653
std::string clim_u_time_varname
Name of time field for u climatology data.
Definition REMORA.H:2116
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:930
int foextrap_bc() const noexcept
Definition REMORA.H:1493
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:1688
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:1100
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
Definition REMORA.H:1730
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::Real check_plot_z_tol
abort when the coarse-fine mismatch at interior nodes exceeds this; negative (the default) only repor...
Definition REMORA.H:1969
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:1449
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:1664
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:1495
void extrapolate_metric_to_physical_boundaries(amrex::MultiFab &mf, const amrex::Geometry &geom)
Extrapolate grid metrics to edge of MultiFab.
Definition REMORA.cpp:853
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:2112
std::unique_ptr< NCTimeSeries > u_clim_data_from_file
Data container for u-velocity climatology data read from file.
Definition REMORA.H:1651
std::string check_file
Checkpoint file prefix.
Definition REMORA.H:1982
static amrex::Real startCPUTime
Variable for CPU timing.
Definition REMORA.H:2155
int check_plot_z
check the nodal z a viewer rebuilds from the plotfile's Nu_nd set against z_phys_nd on each level,...
Definition REMORA.H:1965
int cf_flux_pc
distribute the parent's interface mass flux piecewise-constantly over the fine faces under each paren...
Definition REMORA.H:1930
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm_full_domain
horizontal scaling factor: 1 / dx (2D) on whole domain
Definition REMORA.H:607
bool plot_wvel
Whether to write z_velocity, the true vertical velocity, to NetCDF output as w.
Definition REMORA.H:2007
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:1894
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:3275
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:3249
static bool plot_nodal_data
Whether to write nodal data (Nu_nd) to plotfiles.
Definition REMORA.H:2067
amrex::Vector< std::string > history_file_in_use
Per level, the history file this run last wrote to.
Definition REMORA.H:1995
int regrid_int
how often each level regrids the higher levels of refinement (after a level advances that many time s...
Definition REMORA.H:1972
amrex::Real check_int_time
Checkpoint output interval in seconds.
Definition REMORA.H:1986
amrex::Box nc_hires_init_box
Box for the full domain at nc_hires_init_level.
Definition REMORA.H:2091
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:245
void compute_omega(int lev, amrex::MultiFab &mf_omega, const amrex::MultiFab &mf_Huon, const amrex::MultiFab &mf_Hvom)
Velocity across the w-levels (omega, m/s) from the given mass fluxes.
int zeta_bc() const noexcept
Definition REMORA.H:1490
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:1783
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:1796
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:642
int num_bdy_vars() const noexcept
Definition REMORA.H:1504
amrex::Vector< amrex::IntVect > cum_ref_ratios
Cumulative refinement ratio between level 0 and level i.
Definition REMORA.H:2094
const amrex::Vector< std::string > derived_names_3d
Names of derived fields for 3d plotfile fields.
Definition REMORA.H:2012
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:1980
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_dmde
d(1/m)/d(eta)
Definition REMORA.H:644
void compute_wvel(int lev, amrex::MultiFab &mf_w, const amrex::MultiFab &mf_omega)
As compute_wvel, from an omega already computed by compute_diagnostic_omega.
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:1728
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:1698
void AverageDownTo(int crse_lev)
more flexible version of AverageDown() that lets you average down across multiple levels
Definition REMORA.cpp:2940
int steps_per_history_file
Time steps per netcdf history file. Must be > 0 if chunk_history_file.
Definition REMORA.H:1991
void post_timestep(int nstep, amrex::Real time, amrex::Real dt_lev)
Called after every level 0 timestep.
Definition REMORA.cpp:441
int max_step
maximum number of steps
Definition REMORA.H:1814
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:1624
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:1379
amrex::Vector< std::string > nc_frc_file
NetCDF forcing file(s)
Definition REMORA.H:2097
amrex::Vector< int > num_boxes_at_level
how many boxes specified at each level by tagging criteria
Definition REMORA.H:1726
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:1494
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:1836
int last_check_file_step
Step when we last output a checkpoint file.
Definition REMORA.H:1804
int bdy_zeta() const noexcept
Definition REMORA.H:1503
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:2114
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:1735
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
Definition REMORA.H:1754
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:1644
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:1978
std::unique_ptr< NCTimeSeries > cloud_data_from_file
Data container for cloud cover fraction read from file.
Definition REMORA.H:1642
amrex::Real getCPUTime() const
Get CPU time used.
Definition REMORA.H:2161
amrex::YAFluxRegister * getAdvFluxReg(int lev)
flux register between lev and lev-1
Definition REMORA.H:1760
void inject_mask_outside_domain(int lev)
Give lev's rho-mask ghost cells beyond the domain the coarser level's values.
Definition REMORA.cpp:1060
int nbio
Number of biology tracers, set by the active biology model. Zero when no biology model is active.
Definition REMORA.H:1833
void WriteAtFinalTime()
Write checkpoint and plotfiles at end of simulation.
Definition REMORA.cpp:344
void InitData()
Initialize multilevel data.
Definition REMORA.cpp:466
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:2866
void set3DPlotVariables(const std::string &pp_plot_var_names_3d)
amrex::Vector< int > istep
which step?
Definition REMORA.H:1733
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:2104
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:2175
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:2192
void set_analytic_vmix(int lev)
Set vertical mixing coefficients from analytic.
Definition REMORA.cpp:976
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:1121
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:2109
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:2061
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:1700
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:1636
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:715
static amrex::Real change_max
Fraction maximum change in subsequent time steps.
Definition REMORA.H:1864
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:1959
int num_bio() const noexcept
Number of biology tracers carried in the state.
Definition REMORA.H:2226
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:1702
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:754
amrex::Vector< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
Definition REMORA.H:388
void readTracersParams()
Read tracer and hydro particles parameters.
std::unique_ptr< NCTimeSeries > ubar_clim_data_from_file
Data container for ubar climatology data read from file.
Definition REMORA.H:1647
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
bool m_use_tracer_particles
tracer particles that advect with flow
Definition REMORA.H:2034
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:216
amrex::Vector< REMORAFillPatcher > FPr_c
Vector over levels of FillPatchers for scalars.
Definition REMORA.H:1686
int hires_init_level
Which level the high resolution initialization data is at.
Definition REMORA.H:2087
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:2121
std::unique_ptr< NCTimeSeries > Tair_data_from_file
Data container for air temperature read from file.
Definition REMORA.H:1630
int bdy_vbar() const noexcept
Definition REMORA.H:1502
int cf_avgdown_bar
Definition REMORA.H:1911
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:2232
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:1830
std::string clim_v_time_varname
Name of time field for v climatology data.
Definition REMORA.H:2118
amrex::Vector< REMORAFillPatcher > FPr_w
Vector over levels of FillPatchers for w.
Definition REMORA.H:1692
void plot_node_coords(amrex::Vector< amrex::MultiFab > &mf_xy)
Physical (x, y) of the psi points on every level, for plotfile output.
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:1626
std::unique_ptr< NCTimeSeries > Pair_data_from_file
Data container for air pressure read from file.
Definition REMORA.H:1634
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:1902
amrex::Vector< amrex::Real > t_new
new time at each level, in seconds since start_time
Definition REMORA.H:1744
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:2017
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:1671
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:999
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:1667
int cf_set_width
Width for fixing values at coarse-fine interface.
Definition REMORA.H:1683
int cf_avgdown_volume_weighted
average the fine tracers onto the coarse weighted by cell volume, Hz/(pm*pn), rather than by area as ...
Definition REMORA.H:1947
int biology_debug_j
Target column j index for biology_debug = 1.
Definition REMORA.H:1858
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:2209
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:1889
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:2690
void sum_integrated_quantities(amrex::Real time)
Integrate conserved quantities for diagnostics.
static int total_nc_plot_file_step
Definition REMORA.H:1517
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:1501
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:1884
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:1488
amrex::Gpu::DeviceVector< int > river_direction
Vector over rivers of river direction: 0: u-face; 1: v-face; 2: w-face.
Definition REMORA.H:1673
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:2084
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:2020
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:1808
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:3121
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:2149
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:2125
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:1696
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:1489
std::unique_ptr< NCTimeSeries > Vwind_data_from_file
Data container for v-direction wind read from file.
Definition REMORA.H:1628
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:1868
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:1657
void set_hmixcoef(int lev)
Initialize horizontal mixing coefficients.
Definition REMORA.cpp:1424
amrex::Array< std::string, 2 *AMREX_SPACEDIM > domain_bc_type
Array of strings describing domain boundary conditions.
Definition REMORA.H:1777
amrex::Vector< std::unique_ptr< NCTimeSeriesRiver > > river_source_cons
Vector of data containers for scalar data in rivers.
Definition REMORA.H:1660
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
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:1662
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:1924
void init_grid_vars_full_domain_from_netcdf()
Full domain high-res grid variable initialization from NetCDF file.
void compute_wvel(int lev, amrex::MultiFab &mf_w)
"True" vertical velocity w (m/s) at w-points, as ROMS wvelocity
void AverageDown()
set covered coarse cells to be the average of overlying fine cells
Definition REMORA.cpp:2671
amrex::Real netcdf_fill_value
fill value for masked arrays in netcdf output
Definition REMORA.H:2025
void set_nsubsteps(int nlevs_max)
size nsubsteps and set how many steps each level takes per parent step
Definition REMORA.cpp:2824
int bdy_cons(int icomp) const noexcept
Accessors for the ncons-dependent entries of BdyVars.
Definition REMORA.H:1500
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 check_plot_nodal_z(const amrex::Vector< const amrex::MultiFab * > &nd, const amrex::Vector< amrex::Geometry > &g)
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:1939
AMREX_FORCE_INLINE std::ostream & DataLog(int i)
Helper function for IO stream.
Definition REMORA.H:2142
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:1910
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:2188
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akv
Vertical viscosity coefficient (3D)
Definition REMORA.H:442
void evolveTracers(int lev, amrex::Real dt, amrex::Vector< amrex::MultiFab const * > &flow_vel, const amrex::Vector< std::unique_ptr< amrex::MultiFab > > &)
Evolve tracers and hydro particles.
static amrex::Real cfl
CFL condition.
Definition REMORA.H:1862
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:1790
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:1843
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:2001
amrex::Real elapsed_time(double time) const noexcept
Elapsed time since start_time of a time on the model clock.
Definition REMORA.H:2216
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:913
long long history_restart_record(int lev, const std::string &path)
Record at which a restarted run continues a history file.
static int verbose
Verbosity level of output.
Definition REMORA.H:2053
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
static void compute_W(const amrex::Box &bx2d, const amrex::Array4< amrex::Real > &W, const amrex::Array4< amrex::Real const > &Huon, const amrex::Array4< amrex::Real const > &Hvom, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &h, const int N)
Vertical volume flux W from the horizontal mass flux divergence.
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.
ParticleData particleData
Particle container with all particle species.
Definition REMORA.H:2030
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:1976
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:1984
amrex::Real check_cf_tol
tolerance for the above
Definition REMORA.H:1961
void set_smflux(int lev)
Initialize or calculate surface momentum flux from file or analytic.
Definition REMORA.cpp:1709
void WritePlotFile(int istep)
main driver for writing AMReX plotfiles
std::string restart_chkfile
If set, restart from this checkpoint file.
Definition REMORA.H:1825
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:3354
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:1681
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:2264
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:1799
amrex::Vector< std::string > plot_var_names_2d
Names of 2D variables to output to AMReX plotfile.
Definition REMORA.H:2003
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:1851
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:1746
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:2210
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:2224
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:1919
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:1780
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:1806
static amrex::Vector< REMORAErrorTag > ref_tags
Holds info for dynamically generated tagging criteria.
Definition REMORA.H:2134
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:813
amrex::Vector< amrex::Real > dt
time step at each level
Definition REMORA.H:1748
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:2058
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:1774
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:2080
amrex::Vector< long long > history_record_shift
Per level, history_count minus the record written in the file in use. Nonzero only after a restart.
Definition REMORA.H:1998
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:698
int reflux_clamp
stop that correction driving a tracer negative, as ROMS does. On by default to match ROMS; costs exac...
Definition REMORA.H:1955
std::unique_ptr< NCTimeSeries > vbar_clim_data_from_file
Data container for vbar climatology data read from file.
Definition REMORA.H:1649
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:2014
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:1846
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.