added release '2011'.
added toolsPath() method. added optional release hinting for path determinations. streamlined submit_job method.
This commit is contained in:
parent
6a5733e53e
commit
4eb754b1fb
|
@ -10,6 +10,7 @@ class Marc(Solver):
|
||||||
#--------------------------
|
#--------------------------
|
||||||
self.solver = 'Marc'
|
self.solver = 'Marc'
|
||||||
self.releases = { \
|
self.releases = { \
|
||||||
|
'2011': ['linux64',''],
|
||||||
'2010.2':['linux64',''],
|
'2010.2':['linux64',''],
|
||||||
'2010': ['linux64',''],
|
'2010': ['linux64',''],
|
||||||
'2008r1':[''],
|
'2008r1':[''],
|
||||||
|
@ -27,22 +28,25 @@ class Marc(Solver):
|
||||||
|
|
||||||
for release,subdirs in sorted(self.releases.items(),reverse=True):
|
for release,subdirs in sorted(self.releases.items(),reverse=True):
|
||||||
for subdir in subdirs:
|
for subdir in subdirs:
|
||||||
libPath = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
path = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
||||||
if os.path.exists(libPath): return release
|
if os.path.exists(path): return release
|
||||||
else: continue
|
else: continue
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
#--------------------------
|
#--------------------------
|
||||||
def libraryPath(self,rootRelation = ''):
|
def libraryPath(self,rootRelation = '',releases = []):
|
||||||
#--------------------------
|
#--------------------------
|
||||||
import os,damask.environment
|
import os,damask.environment
|
||||||
|
|
||||||
MSCpath = damask.environment.Environment(rootRelation).pathInfo['msc']
|
MSCpath = damask.environment.Environment(rootRelation).pathInfo['msc']
|
||||||
|
|
||||||
for release,subdirs in sorted(self.releases.items(),reverse=True):
|
if len(releases) == 0: releases = self.releases.keys()
|
||||||
for subdir in subdirs:
|
if type(releases) is not list: releases = [releases]
|
||||||
|
for release in sorted(releases,reverse=True):
|
||||||
|
if release not in self.releases: continue
|
||||||
|
for subdir in self.releases[release]:
|
||||||
libPath = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
libPath = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
||||||
if os.path.exists(libPath): return libPath
|
if os.path.exists(libPath): return libPath
|
||||||
else: continue
|
else: continue
|
||||||
|
@ -50,64 +54,65 @@ class Marc(Solver):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------
|
||||||
|
def toolsPath(self,rootRelation = '',release = ''):
|
||||||
|
#--------------------------
|
||||||
|
import os,damask.environment
|
||||||
|
|
||||||
|
MSCpath = damask.environment.Environment(rootRelation).pathInfo['msc']
|
||||||
|
|
||||||
|
if len(release) == 0: release = self.version(rootRelation)
|
||||||
|
path = '%s/marc%s/tools'%(MSCpath,release)
|
||||||
|
if os.path.exists(path): return path
|
||||||
|
else: return ''
|
||||||
|
|
||||||
|
|
||||||
#--------------------------
|
#--------------------------
|
||||||
def submit_job(self,
|
def submit_job(self,
|
||||||
#--------------------------
|
#--------------------------
|
||||||
rootRelation = '',
|
rootRelation = '',
|
||||||
run_marc_path='/msc/marc2010/tools/',
|
release = '',
|
||||||
subroutine_dir=None,
|
model = 'model',
|
||||||
subroutine_name='DAMASK_marc2010',
|
job = 'job1',
|
||||||
compile=False,
|
logfile = None,
|
||||||
compiled_dir='../../../code/',
|
compile = False,
|
||||||
modelname='one_element_model',
|
):
|
||||||
jobname='job1',
|
|
||||||
#IOdir='',
|
import os,damask.environment
|
||||||
host=[]
|
import subprocess,shlex,shutil
|
||||||
):
|
|
||||||
import os,damask.environment
|
if len(release) == 0: release = self.version(rootRelation)
|
||||||
import subprocess, shlex
|
|
||||||
import shutil
|
damaskEnv = damask.environment.Environment(rootRelation)
|
||||||
|
|
||||||
damaskEnv = damask.environment.Environment(rootRelation)
|
user = os.path.join(damaskEnv.relPath('code/'),'DAMASK_marc%s'%release)
|
||||||
if subroutine_dir is None: subroutine_dir = damaskEnv.relPath('code/')
|
|
||||||
if subroutine_name is None: subroutine_name = 'DAMASK_marc' + self.version(rootRelation)
|
# Define options [see Marc Installation and Operation Guide, pp 23]
|
||||||
if run_marc_path is None: run_marc_path = os.path.join(damaskEnv.pathInfo['msc'],self.version(rootRelation),'tools/')
|
cmd = os.path.join(self.toolsPath(rootRelation,release),'run_marc') + \
|
||||||
|
' -jid ' + model + '_' + job + \
|
||||||
|
' -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no'
|
||||||
|
|
||||||
|
if compile: cmd += ' -u ' + user+'.f90' + ' -save y'
|
||||||
|
else: cmd += ' -prog ' + user
|
||||||
|
|
||||||
|
print 'job submission with%s compilation: %s'%({False:'out',True:''}[compile],user)
|
||||||
|
|
||||||
# Define all options [see Marc Installation and Operation Guide, pp 23]
|
|
||||||
run_marc = os.path.join(run_marc_path,'run_marc')
|
|
||||||
jid = ' -jid ' + modelname + '_' + jobname
|
|
||||||
compilation=' -u ' + os.path.join(subroutine_dir,subroutine_name+'.f90') + ' -save y'
|
|
||||||
options=' -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no'
|
|
||||||
cmd=run_marc+jid+options
|
|
||||||
|
|
||||||
if compile:
|
|
||||||
cmd += compilation
|
|
||||||
print 'job submission with compilation.'
|
|
||||||
else:
|
|
||||||
shutil.copy2(os.path.join(subroutine_dir,subroutine_name+'.f90'),os.path.join('.',subroutine_name+'.f90'))
|
|
||||||
shutil.copy2(os.path.join(compiled_dir,subroutine_name+'.marc'),os.path.join('.',subroutine_name+'.marc'))
|
|
||||||
prog = ' -prog ' + subroutine_name
|
|
||||||
cmd += prog
|
|
||||||
print 'Job submission without compilation, using %s'%prog
|
|
||||||
out = open('out.log','w')
|
|
||||||
print(cmd)
|
print(cmd)
|
||||||
#print shlex.split(cmd)
|
self.p = subprocess.Popen(shlex.split(cmd),stdout = logfile,stderr = subprocess.STDOUT)
|
||||||
self.p = subprocess.Popen(shlex.split(cmd),stdout=out,stderr=subprocess.STDOUT)
|
|
||||||
self.p.wait()
|
self.p.wait()
|
||||||
out.close()
|
|
||||||
|
|
||||||
#--------------------------
|
#--------------------------
|
||||||
def exit_number_from_outFile(self,outFile=None):
|
def exit_number_from_outFile(self,outFile=None):
|
||||||
#--------------------------
|
#--------------------------
|
||||||
import string
|
import string
|
||||||
|
exitnumber = -1
|
||||||
fid_out = open(outFile,'r')
|
fid_out = open(outFile,'r')
|
||||||
for ln in fid_out:
|
for ln in fid_out:
|
||||||
if (string.find(ln,'tress iteration') is not -1):
|
if (string.find(ln,'tress iteration') is not -1):
|
||||||
print ln
|
print ln
|
||||||
elif (string.find(ln,'Exit number') is not -1):
|
elif (string.find(ln,'Exit number') is not -1):
|
||||||
substr = ln[string.find(ln,'Exit number'):len(ln)]
|
substr = ln[string.find(ln,'Exit number'):len(ln)]
|
||||||
exitnumber = substr[12:16]
|
exitnumber = int(substr[12:16])
|
||||||
fid_out.close()
|
|
||||||
return int(exitnumber)
|
|
||||||
fid_out.close()
|
fid_out.close()
|
||||||
return -1
|
return exitnumber
|
||||||
|
|
Loading…
Reference in New Issue