Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions SU2_PY/SU2/run/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# ----------------------------------------------------------------------

import os, sys, shutil, copy
import shlex
import subprocess
from ..io import Config
from ..util import which
Expand All @@ -46,7 +47,6 @@
) from exc

sys.path.append(SU2_RUN)
quote = '"' if sys.platform == "win32" else ""

# SU2 suite run command template
base_Command = os.path.join(SU2_RUN, "%s")
Expand Down Expand Up @@ -98,23 +98,23 @@ def CFD(config):

processes = konfig["NUMBER_PART"]

the_Command = "SU2_CFD_DIRECTDIFF%s %s" % (quote, tempname)
the_Command = "SU2_CFD_DIRECTDIFF %s" % tempname

elif auto_diff:
tempname = "config_CFD_AD.cfg"
konfig.dump(tempname)

processes = konfig["NUMBER_PART"]

the_Command = "SU2_CFD_AD%s %s" % (quote, tempname)
the_Command = "SU2_CFD_AD %s" % tempname

else:
tempname = "config_CFD.cfg"
konfig.dump(tempname)

processes = konfig["NUMBER_PART"]

the_Command = "SU2_CFD%s %s" % (quote, tempname)
the_Command = "SU2_CFD %s" % tempname

the_Command = build_command(the_Command, processes)
run_command(the_Command)
Expand All @@ -137,7 +137,7 @@ def DEF(config):
# must run with rank 1
processes = konfig["NUMBER_PART"]

the_Command = "SU2_DEF%s %s" % (quote, tempname)
the_Command = "SU2_DEF %s" % tempname
the_Command = build_command(the_Command, processes)
run_command(the_Command)

Expand All @@ -164,15 +164,15 @@ def DOT(config):

processes = konfig["NUMBER_PART"]

the_Command = "SU2_DOT_AD%s %s" % (quote, tempname)
the_Command = "SU2_DOT_AD %s" % tempname
else:

tempname = "config_DOT.cfg"
konfig.dump(tempname)

processes = konfig["NUMBER_PART"]

the_Command = "SU2_DOT%s %s" % (quote, tempname)
the_Command = "SU2_DOT %s" % tempname

the_Command = build_command(the_Command, processes)
run_command(the_Command)
Expand All @@ -195,7 +195,7 @@ def GEO(config):
# must run with rank 1
processes = konfig["NUMBER_PART"]

the_Command = "SU2_GEO%s %s" % (quote, tempname)
the_Command = "SU2_GEO %s" % tempname
the_Command = build_command(the_Command, processes)
run_command(the_Command)

Expand All @@ -217,7 +217,7 @@ def SOL(config):
# must run with rank 1
processes = konfig["NUMBER_PART"]

the_Command = "SU2_SOL%s %s" % (quote, tempname)
the_Command = "SU2_SOL %s" % tempname
the_Command = build_command(the_Command, processes)
run_command(the_Command)

Expand All @@ -239,7 +239,7 @@ def SOL_FSI(config):
# must run with rank 1
processes = konfig["NUMBER_PART"]

the_Command = "SU2_SOL%s %s 2" % (quote, tempname)
the_Command = "SU2_SOL %s 2" % tempname
the_Command = build_command(the_Command, processes)
run_command(the_Command)

Expand All @@ -255,7 +255,14 @@ def SOL_FSI(config):

def build_command(the_Command, processes=0):
"""builds an mpi command for given number of processes"""
the_Command = quote + (base_Command % the_Command)
# quote the executable path, SU2_RUN may contain spaces
executable, _, arguments = the_Command.partition(" ")
executable = base_Command % executable
if sys.platform == "win32":
executable = '"%s"' % executable
else:
executable = shlex.quote(executable)
the_Command = "%s %s" % (executable, arguments) if arguments else executable
if processes > 1:
if not mpi_Command:
raise RuntimeError("could not find an mpi interface")
Expand Down