Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Wrapped the call to swiftest_driver in a shell script that is generat…
Browse files Browse the repository at this point in the history
…ed at runtime. Not elegant, but works (so far)
  • Loading branch information
David A Minton committed Nov 16, 2022
1 parent ee0917d commit fdfd6d6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,26 @@ def run(self,**kwargs):

# Get current environment variables
env = os.environ.copy()
driver_script = os.path.join(self.binary_path,"swiftest_driver.sh")
shell = os.path.basename(env['SHELL'])
with open(driver_script,'w') as f:
f.write(f"#{env['SHELL']} -l {os.linesep}")
f.write(f"source ~/.{shell}rc {os.linesep}")
f.write(f"cd {self.sim_dir} {os.linesep}")
f.write(f"pwd {os.linesep}")
f.write(f"{self.driver_executable} {self.integrator} {self.param_file}")

try:
cmd = f"{self.driver_executable} {self.integrator} {self.param_file}"
cmd = f"{env['SHELL']} -l {driver_script}"
p = subprocess.Popen(shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
universal_newlines=True)
for line in p.stdout:
print(line, end='')
for line in p.stderr:
print(line, end='')
res = p.communicate()
if p.returncode != 0:
for line in res[1]:
Expand Down Expand Up @@ -2032,6 +2042,7 @@ def add_solar_system_body(self,
J2=J2, J4=J4, t=t)

dsnew = self._combine_and_fix_dsnew(dsnew)
self.save()

return dsnew

Expand Down Expand Up @@ -2284,6 +2295,7 @@ def input_to_array(val,t,n=None):
J2=J2, J4=J4,t=t)

dsnew = self._combine_and_fix_dsnew(dsnew)
self.save()

return dsnew

Expand Down

0 comments on commit fdfd6d6

Please sign in to comment.