1
Fork 0

Added mpi information to logs

This commit is contained in:
Edgar P. Burkhart 2022-03-03 12:18:46 +01:00
parent eca2636e08
commit 67fa3a09a5
Signed by: edpibu
GPG Key ID: 9833D3C5A25BD227
1 changed files with 12 additions and 6 deletions

View File

@ -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,