Skip to content

Commit

Permalink
Bugfix in creating run script.
Browse files Browse the repository at this point in the history
  • Loading branch information
nwieters authored and pgierz committed Feb 3, 2025
1 parent 9fe12b5 commit 46c5d69
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/esm_runscripts/batch_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from .pbs import Pbs
from .slurm import Slurm

import pdb

known_batch_systems = ["slurm", "pbs"]
reserved_jobtypes = ["prepcompute", "compute", "prepare", "tidy", "inspect"]

Expand Down Expand Up @@ -549,7 +551,6 @@ def write_run_batch_script(config, cluster, batch_or_shell="batch"):
)
runfile.write(self.append_start_statement(config, phase["name"]) + "\n")
runfile.write("\n")
runfile.write("cd " + config["general"]["thisrun_work_dir"] + "\n")

# if cluster in reserved_jobtypes:
config["general"]["batch"].add_pre_launcher_lines(
Expand All @@ -558,8 +559,10 @@ def write_run_batch_script(config, cluster, batch_or_shell="batch"):

command = phase["run_command"]
if phase["phase_type"] == "SimulationSetup":
runfile.write("cd " + config["general"]["experiment_scripts_dir"] + "\n")
runfile.write(f"{command} --run-from-batch-script\n")
elif phase["phase_type"] == "compute":
runfile.write("cd " + config["general"]["thisrun_work_dir"] + "\n")
observe_call = (
"esm_runscripts "
+ config["general"]["started_from"]
Expand All @@ -579,12 +582,19 @@ def write_run_batch_script(config, cluster, batch_or_shell="batch"):
+ " -v "
+ " --last-jobtype "
+ config["general"]["jobtype"]
+ " --open-run"
)
runfile.write(f"{command}\n")
runfile.write("process=$!\n")
runfile.write("\n")
runfile.write("#********** Start to observe " + phase["name"] + " *************\n")
runfile.write("echo start observe >> " + config["general"]["experiment_log_file"] + "\n")
runfile.write("cd " + config["general"]["experiment_scripts_dir"] + "\n")
runfile.write(f"{observe_call}\n")
runfile.write("\n")
runfile.write("wait\n")
runfile.write("echo end observe >> " + config["general"]["experiment_log_file"] + "\n")
doneline = "echo " + line + " >> " + config["general"]["experiment_log_file"]
else:
runfile.write(f"{command}\n")
runfile.write(self.append_done_statement(config, phase["name"]) + "\n")
Expand Down

0 comments on commit 46c5d69

Please sign in to comment.