diff --git a/gusto/core/io.py b/gusto/core/io.py index ebba47815..c7f7f083b 100644 --- a/gusto/core/io.py +++ b/gusto/core/io.py @@ -372,7 +372,7 @@ def setup_dump(self, state_fields, t, pick_up=False): 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. @@ -390,9 +390,10 @@ def setup_dump(self, state_fields, t, pick_up=False): 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, - self.output.point_data, self.output.checkpoint and not pick_up]): + self.output.point_data, self.output.checkpoint]) and not pick_up + 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 diff --git a/gusto/timestepping/timestepper.py b/gusto/timestepping/timestepper.py index 81e52e047..57974e25b 100644 --- a/gusto/timestepping/timestepper.py +++ b/gusto/timestepping/timestepper.py @@ -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 @@ -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) @@ -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) @@ -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)