Skip to content

Commit

Permalink
Merge branch 'enddate' of github.com:C2SM/processing-chain into enddate
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaehn committed Oct 27, 2023
2 parents 00733a0 + ff24793 commit dae2348
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions run_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ def run_chain(work_root, model_cfg, cfg, startdate_sim, enddate_sim, job_names,
enddate_sim_yyyymmddhh_prev = (cfg.enddate_sim - timedelta(hours=cfg.restart_step_hours)).strftime('%Y%m%d%H')

if cfg.second_one: # second run (i.e., get job_id from first run)
startdate_sim_yyyymmddhh_prev = (cfg.enddate_sim - timedelta(hours=2*cfg.restart_step_hours)).strftime('%Y%m%d%H')
else: # all other runs (i.e., get job_id from previous run)
startdate_sim_yyyymmddhh_prev = (cfg.enddate_sim - timedelta(hours=2*cfg.restart_step_hours+cfg.spinup)).strftime('%Y%m%d%H')

cfg.job_id_prev = f'{startdate_sim_yyyymmddhh_prev}_{enddate_sim_yyyymmddhh_prev}'
cfg.job_id_prev = '%s_%d_%d' % (inidate_yyyymmddhh_prev, 0,
hstop)
else: # all other runs
cfg.job_id_prev = '%s_%d_%d' % (inidate_yyyymmddhh_prev,
0 - cfg.spinup, hstop)
cfg.chain_root_prev = os.path.join(work_root, cfg.casename,
cfg.job_id_prev)
cfg.job_id_prev)
cfg.last_cosmo_output = os.path.join(cfg.chain_root_prev, 'cosmo',
'output')

Expand Down Expand Up @@ -470,9 +470,10 @@ def restart_runs(work_root, model_cfg, cfg, job_names, force):
If True will do job regardless of completion status
"""
# run restarts
for startdate_sim in tools.iter_hours(cfg.startdate, cfg.enddate, cfg.restart_step_hours):
startdate_sim = startdate_sim
enddate_sim = startdate_sim + timedelta(hours=cfg.restart_step_hours)
for time in tools.iter_hours(cfg.startdate, cfg.enddate,
cfg.restart_step_hours):
startdate_sim = time
enddate_sim = time + timedelta(hours=cfg.restart_step_hours)
runtime_sim = (enddate_sim - startdate_sim).total_seconds() / 3600

if enddate_sim > cfg.enddate:
Expand Down Expand Up @@ -527,8 +528,12 @@ def restart_runs_spinup(work_root, model_cfg, cfg, job_names, force):
If True will do job regardless of completion status
"""

for startdate_sim in tools.iter_hours(cfg.startdate, cfg.enddate, cfg.restart_step_hours):
if startdate_sim == cfg.startdate:
for time in tools.iter_hours(cfg.startdate, cfg.enddate,
cfg.restart_step_hours):
startdate_sim = time
enddate_sim = time + timedelta(hours=cfg.restart_step_hours)
runtime_sim = (enddate_sim - startdate_sim).total_seconds() / 3600
if time == start:
setattr(cfg, "first_one", True)
setattr(cfg, "second_one", False)
setattr(cfg, "lrestart", '.FALSE.')
Expand Down

0 comments on commit dae2348

Please sign in to comment.