fixed abaqus job submission

This commit is contained in:
Martin Diehl 2014-06-25 08:32:33 +00:00
parent 8b11b1b6b0
commit 28f3ba6841
1 changed files with 16 additions and 14 deletions

View File

@ -7,23 +7,23 @@ from .solver import Solver
class Abaqus(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' self.solver='Abaqus'
if version =='': if version =='':
self.version = version print 'hallo'
cmd = "abaqus information=release"
import subprocess 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] self.version = process.stdout.readlines()[1].split()[1]
print self.version
else: else:
self.version = version self.version = version
if method.lower() in ['','std','standard']: if solver.lower() in ['','std','standard']:
self.method = 'std' self.solver = 'std'
elif method.lower() in ['exp','explicit']: elif solver.lower() in ['exp','explicit']:
self.method = 'exp' self.solver = 'exp'
else: else:
self.method = 'chose either std or exp' raise Exception('unknown Abaqus solver %'%solver)
def return_run_command(self,model): def return_run_command(self,model):
import subprocess import subprocess
@ -32,13 +32,15 @@ class Abaqus(Solver):
env=damask.Environment() env=damask.Environment()
shortVersion = re.sub('[\.,-]', '',self.version) shortVersion = re.sub('[\.,-]', '',self.version)
try: try:
subprocess.Popen(['abq'+shortVersion,'information=release'])
cmd='abq'+shortVersion cmd='abq'+shortVersion
except subprocess.CalledProcessError: subprocess.check_output(['abq'+shortVersion,'information=release'])
process = subprocess.Popen(cmd,stdout = subprocess.PIPE,stderr = subprocess.PIPE,shell=True) except OSError: # link to abqXXX not existing
cmd='abaqus' cmd='abaqus'
if self.version != process.stdout.readlines()[1].split()[1]: raise Exception process = subprocess.Popen(['abaqus','information=release'],stdout = subprocess.PIPE,stderr = subprocess.PIPE)
return '%s -job %s -user %s/code/DAMASK_abaqus_%s interactive'%(cmd,model,env.rootDir(),self.method) 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)