2#include "AMReX_PlotFileUtil.H"
41 if (ParallelDescriptor::IOProcessor()) {
44 VisMF::IO_Buffer
io_buffer(VisMF::IO_Buffer_Size);
48 std::ofstream::trunc |
49 std::ofstream::binary);
86 for (
int i = 0;
i <
istep.size(); ++
i) {
92 for (
int i = 0;
i <
dt.size(); ++
i) {
102 for (
int i = 0;
i <
t_new.size(); ++
i) {
119 for (
int i = 0;
i <
t_new.size(); ++
i) {
137 for (
auto&
b :
bl2d) {
144 VisMF::Write(cons, amrex::MultiFabFileFullPrefix(
lev,
checkpointname,
"Level_",
"Cell"));
147 VisMF::Write(cons, amrex::MultiFabFileFullPrefix(
lev,
checkpointname,
"Level_",
"Cell_old"));
236#ifdef REMORA_USE_PARTICLES
244 amrex::Print() <<
"Restart from checkpoint " <<
restart_chkfile <<
"\n";
249 VisMF::IO_Buffer
io_buffer(VisMF::GetIOBufferSize());
268 amrex::Abort(
"Checkpoint file has more levels than amr.max_level");
281 amrex::Abort(
"Checkpoint holds " + std::to_string(
chk_ncomp) +
282 " cell-centered components but this run has " + std::to_string(
ncons) +
283 ". The count is set by remora.nscalar and by remora.biology_model; "
284 "both must match the run the checkpoint came from.");
334#ifdef AMREX_USE_FLOAT
372 while (std::getline(
is,
line)) {
374 if (!(
lis >>
word)) {
continue; }
375 if (
word ==
"time_origin") {
378 }
else if (
word ==
"elapsed_time") {
381 }
else if (
word ==
"start_time") {
384 }
else if (
word ==
"history_count") {
397 std::ostringstream
msg;
399 msg <<
"remora.start_time is " <<
start_time <<
" but the checkpoint "
401 <<
". The model clock continues where the checkpoint left off, but"
402 <<
" the elapsed time the solver sees is rebased by "
404 <<
" moves with it: analytic forcing that ramps from the start of the run,"
405 <<
" refinement indicator start_time/end_time windows, and the"
406 <<
" plot_int_time/check_int_time cadence. NetCDF time axes and"
407 <<
" start_total_time/end_total_time windows stay where they were."
408 <<
" Keep remora.start_time unchanged to continue the run as it was.";
409 amrex::Warning(
msg.str());
432 DistributionMapping
dm {
chk_ba[
lev], ParallelDescriptor::NProcs() };
441 for (
auto&
b :
bl2d) {
447 VisMF::Read(cons, amrex::MultiFabFileFullPrefix(
lev,
restart_chkfile,
"Level_",
"Cell"));
450 VisMF::Read(cons, amrex::MultiFabFileFullPrefix(
lev,
restart_chkfile,
"Level_",
"Cell_old"));
543#ifdef REMORA_USE_PARTICLES
mf_h setVal(geomdata.ProbHi(2))
void Restart(amrex::ParGDBBase *a_gdb, const std::string &a_fname)
void Checkpoint(const std::string &a_fname) const
static void GotoNextLine(std::istream &is)
utility to skip to next line in Header
int ncons
Number of conserved scalars in the state (temperature + salt + passive scalars + biology tracers)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv2d
v velocity RHS (2D, includes horizontal and vertical advection)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h
multilevel data container for current step's z velocities (largely unused; W stored separately)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ZoBot
Bottom roughness length [m], defined at rho points.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg2
correct time average of barotropic x velocity flux for coupling (2D)
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive tracer
void stretch_transform(int lev)
Calculate vertical stretched coordinates.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
int history_count
Counter for which time index we are writing to in the netcdf history file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_tke
Turbulent kinetic energy.
void ReadCheckpointFile()
read checkpoint file from disk
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_gls
Turbulent generic length scale.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru2d
u velocity RHS (2D, includes horizontal and vertical advection)
amrex::Vector< amrex::MultiFab * > zvel_new
multilevel data container for current step's z velocities (largely unused; W stored separately)
double start_time
Time of the start of the simulation, in seconds on the model clock.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Lscale
Vertical mixing turbulent length scale.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akt
Vertical diffusion coefficient (3D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku
land/sea mask at x-faces (2D)
std::string check_file
Checkpoint file prefix.
amrex::Vector< amrex::MultiFab * > xvel_old
multilevel data container for last step's x velocities (u in ROMS)
amrex::Vector< amrex::MultiFab * > yvel_new
multilevel data container for current step's y velocities (v in ROMS)
amrex::Vector< amrex::MultiFab * > zvel_old
multilevel data container for last step's z velocities (largely unused; W stored separately)
amrex::Vector< amrex::MultiFab * > xvel_new
multilevel data container for current step's x velocities (u in ROMS)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv
land/sea mask at y-faces (2D)
amrex::Vector< int > istep
which step?
void WriteCheckpointFile()
write checkpoint file to disk
static int file_min_digits
Minimum number of digits in plotfile name or chunked history file.
amrex::Vector< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg1
time average of barotropic y velocity flux
amrex::Vector< amrex::Real > t_new
new time at each level, in seconds since start_time
static SolverChoice solverChoice
Container for algorithmic choices.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akk
Turbulent kinetic energy vertical diffusion coefficient.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag2
Quadratic drag coefficient [unitless], defined at rho points.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru
u velocity RHS (3D, includes horizontal and vertical advection)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vbar
barotropic y velocity (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg1
time average of barotropic x velocity flux (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ubar
barotropic x velocity (2D)
amrex::Vector< amrex::MultiFab * > cons_old
multilevel data container for last step's scalar data: temperature, salinity, passive tracer
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg2
correct time average of barotropic y velocity flux for coupling (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akv
Vertical viscosity coefficient (3D)
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::Real elapsed_time(double time) const noexcept
Elapsed time since start_time of a time on the model clock.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag
Linear drag coefficient [m/s], defined at rho points.
ParticleData particleData
Particle container with all particle species.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Zt_avg1
Average of the free surface, zeta (2D)
std::string restart_chkfile
If set, restart from this checkpoint file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv
v velocity RHS (3D, includes horizontal and vertical advection)
int last_plot_file_step
Step when we last output a plotfile.
double model_time(amrex::Real elapsed) const noexcept
Time on the model clock, in seconds, of an elapsed time such as t_new.
amrex::Vector< amrex::Real > dt
time step at each level
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akp
Turbulent length scale vertical diffusion coefficient.
BottomStressType bottom_stress_type
VertMixingType vert_mixing_type