From 67fa3a09a597fee6645e3e479281bff0e2953b0b Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Thu, 3 Mar 2022 12:18:46 +0100 Subject: [PATCH] Added mpi information to logs --- swash/processing/swash.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/swash/processing/swash.py b/swash/processing/swash.py index aa36c31..7e698d3 100644 --- a/swash/processing/swash.py +++ b/swash/processing/swash.py @@ -28,20 +28,26 @@ if out.exists(): with tempfile.TemporaryDirectory(prefix="swash_", dir=".") as tmp_raw: tmpdir = pathlib.Path(tmp_raw) - if config.has_option("swash", "mpi"): - mpi = ("-mpi", config.get("swash", "mpi")) - else: - mpi = () - log.info(f"Copying files to '{tmpdir}'") shutil.copy2(inp, tmpdir) shutil.copytree( pathlib.Path(config.get("data", "out")), tmpdir, dirs_exist_ok=True ) + + if config.has_option("swash", "mpi"): + mpi = ("-mpi", config.get("swash", "mpi")) + log.info(f"Using mpi with {mpi}") + else: + mpi = () + with open(tmpdir.joinpath("sws.log"), "w") as logfile: log.info(f"Runing swash in '{tmpdir}'") + + cmd = (config.get("swash", "swashrun"), "-input", inp.name, *mpi) + log.info(f"Running {cmd}") + subprocess.run( - (config.get("swash", "swashrun"), "-input", inp.name, *mpi), + cmd, cwd=tmpdir, stdout=logfile, stderr=logfile,