| 493 | **************************************************************************/ |
| 494 | |
| 495 | int Solver::solve(int nout, BoutReal timestep) { |
| 496 | |
| 497 | Options& globaloptions = Options::root(); // Default from global options |
| 498 | |
| 499 | if (nout < 0) { |
| 500 | nout = number_output_steps; |
| 501 | timestep = output_timestep; |
| 502 | } else { |
| 503 | number_output_steps = nout; |
| 504 | output_timestep = timestep; |
| 505 | } |
| 506 | |
| 507 | finaliseMonitorPeriods(nout, timestep); |
| 508 | |
| 509 | output_progress.write( |
| 510 | _("Solver running for {:d} outputs with output timestep of {:e}\n"), nout, |
| 511 | timestep); |
| 512 | if (default_monitor_period > 1) { |
| 513 | output_progress.write( |
| 514 | _("Solver running for {:d} outputs with monitor timestep of {:e}\n"), |
| 515 | nout / default_monitor_period, timestep * default_monitor_period); |
| 516 | } |
| 517 | |
| 518 | // Initialise |
| 519 | if (init()) { |
| 520 | throw BoutException(_("Failed to initialise solver-> Aborting\n")); |
| 521 | } |
| 522 | |
| 523 | // Set the run ID |
| 524 | run_restart_from = run_id; // Restarting from the previous run ID |
| 525 | run_id = createRunID(); |
| 526 | |
| 527 | // Put the run ID into the options tree |
| 528 | // Forcing in case the value has been previously set |
| 529 | Options::root()["run"]["run_id"].force(run_id, "Output"); |
| 530 | Options::root()["run"]["run_restart_from"].force(run_restart_from, "Output"); |
| 531 | |
| 532 | /// Run the solver |
| 533 | output_info.write(_("Running simulation\n\n")); |
| 534 | output_info.write("Run ID: {:s}\n", run_id); |
| 535 | if (run_restart_from != default_run_id) { |
| 536 | output_info.write("Restarting from ID: {:s}\n", run_restart_from); |
| 537 | } |
| 538 | |
| 539 | time_t start_time = time(nullptr); |
| 540 | output_progress.write(_("\nRun started at : {:s}\n"), toString(start_time)); |
| 541 | |
| 542 | Timer timer("run"); // Start timer |
| 543 | |
| 544 | const bool restart = |
| 545 | globaloptions["restart"].doc("Load state from restart files?").withDefault(false); |
| 546 | |
| 547 | const bool append = |
| 548 | globaloptions["append"] |
| 549 | .doc("Add new outputs to the end of existing files? If false, overwrite files.") |
| 550 | .withDefault(false); |
| 551 | const bool dump_on_restart = globaloptions["dump_on_restart"] |
| 552 | .doc("Write initial state as time point 0?") |