Skip to content

Commit

Permalink
Fix restart variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaehn committed Jan 31, 2024
1 parent 3c79da1 commit 03370b5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
10 changes: 4 additions & 6 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,10 @@ def get_chunk_list(self):

def get_previous_chunk_id(self, current_chunk_id):
"""Get the previous chunk ID based on the current chunk ID."""
try:
index = self.chunk_list.index(current_chunk_id)
if index > 0:
self.chunk_id_prev = self.chunk_list[index - 1]
except ValueError:
# If the current_chunk_id is not in the list or it's the first chunk
index = self.chunk_list.index(current_chunk_id)
if index > 0:
self.chunk_id_prev = self.chunk_list[index - 1]
else:
self.chunk_id_prev = None

def get_dep_ids(self, job_name, add_dep=None):
Expand Down
5 changes: 3 additions & 2 deletions jobs/prepare_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ def set_cfg_variables(cfg):
cfg.icon_output = cfg.icon_base / 'output'
cfg.icon_output_reduced = cfg.icon_base / 'output_reduced'
cfg.icon_restart_out = cfg.icon_base / 'restart'
cfg.icon_restart_in = cfg.chain_root_prev / 'icon' / 'run'
cfg.icon_input_icbc_prev = cfg.chain_root_prev / 'icon' / 'input' / 'icbc'
if cfg.chunk_id_prev:
cfg.icon_restart_in = cfg.chain_root_prev / 'icon' / 'run'
cfg.icon_input_icbc_prev = cfg.chain_root_prev / 'icon' / 'input' / 'icbc'

cfg.input_files_scratch = {}
for dsc, file in cfg.input_files.items():
Expand Down
12 changes: 6 additions & 6 deletions run_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ def run_chunk(cfg, force, resume):
tools.create_dir(cfg.log_finished_dir, "log_finished")

# Config variables for spinup and restart runs
cfg.cosmo_restart_in = ''
cfg.cosmo_restart_out = ''
if hasattr(cfg, 'spinup'):
if hasattr(cfg, 'chunk_id_prev'):
if cfg.chunk_id_prev:
cfg.chain_root_prev = cfg.work_root / cfg.casename / cfg.chunk_id_prev
cfg.last_cosmo_output = cfg.chain_root_prev / 'cosmo' / 'output'
cfg.cosmo_restart_out = ''
cfg.cosmo_restart_in = ''
elif 'restart' in cfg.workflow['features']:
if hasattr(cfg, 'chunk_id_prev'):
if cfg.chunk_id_prev:
cfg.chain_root_prev = cfg.work_root / cfg.casename / cfg.chunk_id_prev
cfg.cosmo_restart_out = cfg.chain_root / 'cosmo' / 'restart'
cfg.cosmo_restart_in = cfg.chain_root_prev / 'cosmo' / 'restart'
cfg.cosmo_restart_in = cfg.chain_root_prev / 'cosmo' / 'restart'
cfg.cosmo_restart_out = cfg.chain_root / 'cosmo' / 'restart'

if cfg.is_async:
# Empty curent job ids
Expand Down

0 comments on commit 03370b5

Please sign in to comment.