diff --git a/python/ctem/ctem/driver.py b/python/ctem/ctem/driver.py index 32c7f4be..401a29b1 100644 --- a/python/ctem/ctem/driver.py +++ b/python/ctem/ctem/driver.py @@ -3,6 +3,7 @@ import subprocess import shutil from ctem import util +import sys class Simulation: """ @@ -178,14 +179,21 @@ def compute_one_interval(self): """ # Create crater population and display CTEM progress on screen print(self.user['ncount'], ' Calling FORTRAN routine') - with subprocess.Popen([os.path.join(self.user['workingdir'], 'CTEM')], + try: + p = subprocess.Popen([os.path.join(self.user['workingdir'], 'CTEM')], stdout=subprocess.PIPE, - universal_newlines=True) as p: - try: - for line in p.stdout: + stderr=subprocess.PIPE, + universal_newlines=True) + for line in p.stdout: + print(line, end='') + res = p.communicate() + if p.returncode != 0: + for line in res[1]: print(line, end='') - except: - print("Error executing main CTEM program") + raise Exception ("CTEM Failure") + except: + print("Error executing main CTEM program") + sys.exit() return