Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gusto/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
Sets up a series of things used for outputting.

This prepares the model for outputting. First it checks for the
existence the specified outputting directory, so prevent it being
existence of the specified output directory to prevent it being
overwritten unintentionally. It then sets up the output files and the
checkpointing file.

Expand All @@ -390,9 +390,10 @@
raise_parallel_exception = 0
error = None

if any([self.output.dump_vtus, self.output.dump_nc,
setup_dir = any([self.output.dump_vtus, self.output.dump_nc,
self.output.dumplist_latlon, self.output.dump_diagnostics,

Check failure on line 394 in gusto/core/io.py

View workflow job for this annotation

GitHub Actions / Run linter

E128

gusto/core/io.py:394:17: E128 continuation line under-indented for visual indent
self.output.point_data, self.output.checkpoint and not pick_up]):
self.output.point_data, self.output.checkpoint]) and not pick_up

Check failure on line 395 in gusto/core/io.py

View workflow job for this annotation

GitHub Actions / Run linter

E128

gusto/core/io.py:395:17: E128 continuation line under-indented for visual indent
if setup_dir:
# setup output directory and check that it does not already exist
self.dumpdir = path.join("results", self.output.dirname)
running_tests = '--running-tests' in sys.argv or "pytest" in self.output.dirname
Expand Down
15 changes: 9 additions & 6 deletions gusto/timestepping/timestepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, equation, io):

self.equation = equation
self.io = io
self.init_io = True # flag so that IO is only set up once
self.dt = self.equation.domain.dt
self.t = self.equation.domain.t
self.reference_profiles_initialised = False
Expand Down Expand Up @@ -196,7 +197,6 @@ def run(self, t, tmax, pick_up=False):
tmax (float): the end time of the run
pick_up: (bool): specify whether to pick_up from a previous run
"""

# Set up diagnostics, which may set up some fields necessary to pick up
self.io.setup_diagnostics(self.fields)
self.io.setup_log_courant(self.fields)
Expand All @@ -207,6 +207,14 @@ def run(self, t, tmax, pick_up=False):
self.io.setup_log_courant(self.fields, name='transporting_velocity',
expression=self.transporting_velocity)

if self.init_io:
# Set up dump, which may also include an initial dump
with timed_stage("Dump output"):
logger.debug('Dumping output to disk')
self.io.setup_dump(self.fields, t, pick_up)

self.init_io = False

if pick_up:
# Pick up fields, and return other info to be picked up
time_data, reference_profiles = self.io.pick_up_from_checkpoint(self.fields)
Expand All @@ -220,11 +228,6 @@ def run(self, t, tmax, pick_up=False):
else:
self.step = 1

# Set up dump, which may also include an initial dump
with timed_stage("Dump output"):
logger.debug('Dumping output to disk')
self.io.setup_dump(self.fields, t, pick_up)

self.log_field_stats()

self.t.assign(t)
Expand Down
Loading