Skip to content

Commit

Permalink
Merge pull request #83 Fix CABLE non-zero exit code behaviour
Browse files Browse the repository at this point in the history
Fix #56
  • Loading branch information
ccarouge authored May 24, 2023
2 parents 33b8f9e + 93d406e commit 528b9cf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions benchcab/run_cable_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
CABLE_EXE,
CABLE_NML,
CABLE_STDOUT_FILENAME,
NUM_CORES
NUM_CORES,
)
from benchcab.task import Task

Expand Down Expand Up @@ -62,20 +62,23 @@ def run_tasks(tasks: list[Task], verbose=False):
task_name = task.get_task_name()
task_dir = CWD / SITE_TASKS_DIR / task_name
if verbose:
print(f"Running task {task_name}... CABLE standard output "
f"saved in {task_dir / CABLE_STDOUT_FILENAME}")
print(
f"Running task {task_name}... CABLE standard output "
f"saved in {task_dir / CABLE_STDOUT_FILENAME}"
)

if verbose:
print(f" cd {task_dir}")
os.chdir(task_dir)

cmd = f"./{CABLE_EXE} {CABLE_NML} > {CABLE_STDOUT_FILENAME}"
cmd = f"./{CABLE_EXE} {CABLE_NML} > {CABLE_STDOUT_FILENAME} 2>&1"
try:
if verbose:
print(f" {cmd}")
subprocess.run(cmd, shell=True, check=True)
except subprocess.CalledProcessError as err:
print("Job failed to submit: ", err.cmd)
except subprocess.CalledProcessError:
print(f"Error: CABLE returned an error for task {task_name}")
continue

output_file = CWD / SITE_OUTPUT_DIR / task.get_output_filename()
if verbose:
Expand Down

0 comments on commit 528b9cf

Please sign in to comment.