1
Fork 0

Changed swash to use provided path in conf

This commit is contained in:
Edgar P. Burkhart 2022-03-03 12:53:28 +01:00
parent 0860faf8c3
commit 96d51e4a61
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 6 additions and 10 deletions

View file

@ -12,8 +12,8 @@ out=out_data
[swash]
input=sws/INPUT.sws
swashrun=/opt/swash/swash/swashrun
out=out
path=/opt/swash
out=out_sws
mpi=4
[post]

View file

@ -30,9 +30,7 @@ with tempfile.TemporaryDirectory(prefix="swash_", dir=".") as tmp_raw:
log.info(f"Copying files to '{tmpdir}'")
shutil.copy2(inp, tmpdir)
shutil.copytree(
pathlib.Path(config.get("data", "out")), tmpdir, dirs_exist_ok=True
)
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"))
@ -42,15 +40,13 @@ with tempfile.TemporaryDirectory(prefix="swash_", dir=".") as tmp_raw:
with open(tmpdir.joinpath("sws.log"), "w") as logfile:
log.info(f"Runing swash in '{tmpdir}'")
path = pathlib.Path(config.get("swash", "swashrun"))
cmd = (config.get("swash", "swashrun"), *mpi, "-input", inp.name)
cmd = (path.joinpath("swashrun"), *mpi, "-input", inp.name)
log.info(f"Running {cmd}")
swash_run = subprocess.Popen(
cmd,
cwd=tmpdir,
stdout=logfile,
stderr=logfile,
cmd, cwd=tmpdir, stdout=logfile, stderr=logfile, env={"PATH": path}
)
code = swash_run.wait()