Skip to content

Commit

Permalink
Merge branch 'config_yaml' of github.com:C2SM/processing-chain into c…
Browse files Browse the repository at this point in the history
…onfig_yaml
  • Loading branch information
mjaehn committed Sep 29, 2023
2 parents f198c26 + 69e46ab commit ffaa26c
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions jobs/cosmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def main(starttime, hstart, hstop, cfg, model_cfg):
tools.create_dir(cfg.cosmo_output, "cosmo_output")

# Total number of processes
np_tot = int(cfg.cosmo['np_x'] * cfg.cosmo['np_y'] / cfg.ntasks_per_node) + cfg.cosmo['np_io']
np_tot = int(cfg.cosmo['np_x'] * cfg.cosmo['np_y'] /
cfg.ntasks_per_node) + cfg.cosmo['np_io']

# If an laf* file is used for initialization,
# copy this to to 'cosmo/input/initial/' or merge with fieldextra
Expand Down Expand Up @@ -166,8 +167,9 @@ def main(starttime, hstart, hstop, cfg, model_cfg):
namelist_names += ['OAE']

for section in namelist_names:
namelist_file = os.path.join(cfg.chain_src_dir, 'cases', cfg.casename,
cfg.cosmo['namelist_prefix'] + section + ".cfg")
namelist_file = os.path.join(
cfg.chain_src_dir, 'cases', cfg.casename,
cfg.cosmo['namelist_prefix'] + section + ".cfg")
with open(namelist_file) as input_file:
cosmo_namelist = input_file.read()

Expand All @@ -185,13 +187,13 @@ def main(starttime, hstart, hstop, cfg, model_cfg):
restart_step=12)
else:
# built-in restarts
cosmo_namelist = cosmo_namelist.format(cfg=cfg,
**cfg.cosmo,
**cfg.oem,
restart_start=cfg.hstart +
cfg.restart_step,
restart_stop=cfg.hstop,
restart_step=cfg.restart_step)
cosmo_namelist = cosmo_namelist.format(
cfg=cfg,
**cfg.cosmo,
**cfg.oem,
restart_start=cfg.hstart + cfg.restart_step,
restart_stop=cfg.hstop,
restart_step=cfg.restart_step)
outf.write(cosmo_namelist)

# Append INPUT_GHG namelist with tracer definitions from csv file
Expand All @@ -203,18 +205,18 @@ def main(starttime, hstart, hstop, cfg, model_cfg):

# Write run script (run.job)
runscript_file = os.path.join(cfg.chain_src_dir, 'cases', cfg.casename,
cfg.cosmo['runjob_filename'])
cfg.cosmo['runjob_filename'])
with open(runscript_file) as input_file:
cosmo_runscript = input_file.read()

output_file = os.path.join(cfg.cosmo_work, "run.job")
with open(output_file, "w") as outf:
outf.write(
cosmo_runscript.format(cfg=cfg,
**cfg.cosmo,
np_tot=np_tot,
logfile=logfile,
logfile_finish=logfile_finish))
**cfg.cosmo,
np_tot=np_tot,
logfile=logfile,
logfile_finish=logfile_finish))

result = subprocess.run(
["sbatch", "--wait",
Expand Down

0 comments on commit ffaa26c

Please sign in to comment.