From 28f3ba6841e088cfbd24c0401ca8a6b062e04f65 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 25 Jun 2014 08:32:33 +0000 Subject: [PATCH] fixed abaqus job submission --- lib/damask/solver/abaqus.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/damask/solver/abaqus.py b/lib/damask/solver/abaqus.py index 0146af7d2..1b1b5c612 100644 --- a/lib/damask/solver/abaqus.py +++ b/lib/damask/solver/abaqus.py @@ -7,23 +7,23 @@ from .solver import Solver class Abaqus(Solver): - def __init__(self,version='',method=''): + def __init__(self,version='',solver=''): # example of version string: 6.12-2, solver: either std or exp self.solver='Abaqus' if version =='': - self.version = version - cmd = "abaqus information=release" + print 'hallo' import subprocess - process = subprocess.Popen(cmd,stdout = subprocess.PIPE,stderr = subprocess.PIPE,shell=True) + process = subprocess.Popen(['abaqus', 'information=release'],stdout = subprocess.PIPE,stderr = subprocess.PIPE) self.version = process.stdout.readlines()[1].split()[1] + print self.version else: self.version = version - if method.lower() in ['','std','standard']: - self.method = 'std' - elif method.lower() in ['exp','explicit']: - self.method = 'exp' + if solver.lower() in ['','std','standard']: + self.solver = 'std' + elif solver.lower() in ['exp','explicit']: + self.solver = 'exp' else: - self.method = 'chose either std or exp' + raise Exception('unknown Abaqus solver %'%solver) def return_run_command(self,model): import subprocess @@ -32,13 +32,15 @@ class Abaqus(Solver): env=damask.Environment() shortVersion = re.sub('[\.,-]', '',self.version) try: - subprocess.Popen(['abq'+shortVersion,'information=release']) cmd='abq'+shortVersion - except subprocess.CalledProcessError: - process = subprocess.Popen(cmd,stdout = subprocess.PIPE,stderr = subprocess.PIPE,shell=True) + subprocess.check_output(['abq'+shortVersion,'information=release']) + except OSError: # link to abqXXX not existing cmd='abaqus' - if self.version != process.stdout.readlines()[1].split()[1]: raise Exception - return '%s -job %s -user %s/code/DAMASK_abaqus_%s interactive'%(cmd,model,env.rootDir(),self.method) + process = subprocess.Popen(['abaqus','information=release'],stdout = subprocess.PIPE,stderr = subprocess.PIPE) + detectedVersion = process.stdout.readlines()[1].split()[1] + if self.version != detectedVersion: + raise Exception('found Abaqus version %s, but requested %s'%(detectedVersion,self.version)) + return '%s -job %s -user %s/code/DAMASK_abaqus_%s interactive'%(cmd,model,env.rootDir(),self.solver)