Commit 25b5d62f authored by David Deepwell's avatar David Deepwell
Browse files

Move restart sequence checking into Options.cpp

The generic code block to check the restart sequence is not needed
in the case file and has been moved into Options.cpp. This
streamlines the case file and makes a single copy for all other
case files to use.
parent a1a18e74
......@@ -227,3 +227,29 @@ void adjust_for_dump(bool & restarting, double & restart_time, int & restart_seq
avg_write_time = max(write_time_per_G*Num_fields*Nx*Ny*Nz/pow(512.0,3), 20.0);
}
}
// check restart sequence
void check_restart_sequence(const bool restarting, int & restart_sequence,
double & initial_time, const double plot_interval) {
if (restarting) {
if (restart_sequence <= 0) {
restart_sequence = int(initial_time/plot_interval);
}
if (master()) {
fprintf(stdout,"Restart flags detected\n");
fprintf(stdout,"Restarting from time %g, at sequence number %d\n",
initial_time,restart_sequence);
}
} else {
// Not restarting, so set the initial sequence number
// to the initial time / plot_interval
restart_sequence = int(initial_time/plot_interval);
if (fmod(initial_time,plot_interval) != 0.0) {
if (master()) {
fprintf(stdout,"Warning: the initial time (%g) does not appear "
"to be an even multiple of the plot interval (%g)\n",
initial_time,plot_interval);
}
}
}
}
......@@ -67,4 +67,7 @@ void options_parse(int argc, char ** argv);
void adjust_for_dump(bool & restarting, double & restart_time, int & restart_sequence,
const double final_time, const double compute_time, double & avg_write_time,
const int Num_tracers, const int Nx, const int Ny, const int Nz);
void check_restart_sequence(const bool restarting, int & restart_sequence,
double & initial_time, const double plot_interval);
#endif
......@@ -415,6 +415,9 @@ int main(int argc, char ** argv) {
final_time, compute_time, avg_write_time, Num_tracers, Nx, Ny, Nz);
}
// check restart sequence
check_restart_sequence(restarting, restart_sequence, initial_time, plot_interval);
// parse expansion types
parse_boundary_conditions(xgrid_type, ygrid_type, zgrid_type, intype_x, intype_y, intype_z);
......@@ -426,30 +429,6 @@ int main(int argc, char ** argv) {
"Ly has been changed to 1.0 for normalization.\n");
}
/* ------------------ Set correct initial time, and sequence --------------------- */
if (restarting) {
if (restart_sequence <= 0) {
restart_sequence = int(initial_time/plot_interval);
}
if (master()) {
fprintf(stdout,"Restart flags detected\n");
fprintf(stdout,"Restarting from time %g, at sequence number %d\n",
initial_time,restart_sequence);
}
} else {
// Not restarting, so set the initial sequence number
// to the initial time / plot_interval
restart_sequence = int(initial_time/plot_interval);
if (fmod(initial_time,plot_interval) != 0.0) {
if (master()) {
fprintf(stdout,"Warning: the initial time (%g) does not appear "
"to be an even multiple of the plot interval (%g)\n",
initial_time,plot_interval);
}
}
}
/* ------------------ Derived parameters --------------------- */
// Dynamic viscosity
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment