2014-04-02 00:11:14 +05:30
|
|
|
# -*- coding: UTF-8 no BOM -*-
|
|
|
|
|
2011-12-22 16:00:25 +05:30
|
|
|
# $Id$
|
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
from .solver import Solver
|
|
|
|
|
|
|
|
|
|
|
|
class Marc(Solver):
|
|
|
|
|
|
|
|
#--------------------------
|
|
|
|
def __init__(self):
|
|
|
|
#--------------------------
|
|
|
|
self.solver = 'Marc'
|
|
|
|
self.releases = { \
|
2014-03-07 14:52:04 +05:30
|
|
|
'2013.1':['linux64',''],
|
|
|
|
'2013': ['linux64',''],
|
2012-12-13 23:20:00 +05:30
|
|
|
'2012': ['linux64',''],
|
2012-01-18 15:11:10 +05:30
|
|
|
'2011': ['linux64',''],
|
2011-12-15 14:21:16 +05:30
|
|
|
'2010.2':['linux64',''],
|
|
|
|
'2010': ['linux64',''],
|
|
|
|
'2008r1':[''],
|
|
|
|
'2007r1':[''],
|
|
|
|
'2005r3':[''],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------
|
|
|
|
def version(self,rootRelation = ''):
|
|
|
|
#--------------------------
|
|
|
|
import os,damask.environment
|
|
|
|
|
2014-01-17 03:10:54 +05:30
|
|
|
MSCpath = damask.environment.Environment(rootRelation).options['MSC_ROOT']
|
2011-12-15 14:21:16 +05:30
|
|
|
|
|
|
|
for release,subdirs in sorted(self.releases.items(),reverse=True):
|
|
|
|
for subdir in subdirs:
|
2012-01-18 15:11:10 +05:30
|
|
|
path = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
|
|
|
if os.path.exists(path): return release
|
2011-12-15 14:21:16 +05:30
|
|
|
else: continue
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------
|
2012-01-18 15:11:10 +05:30
|
|
|
def libraryPath(self,rootRelation = '',releases = []):
|
2011-12-15 14:21:16 +05:30
|
|
|
#--------------------------
|
|
|
|
import os,damask.environment
|
|
|
|
|
2014-01-17 03:10:54 +05:30
|
|
|
MSCpath = damask.environment.Environment(rootRelation).options['MSC_ROOT']
|
2011-12-15 14:21:16 +05:30
|
|
|
|
2012-01-18 15:11:10 +05:30
|
|
|
if len(releases) == 0: releases = self.releases.keys()
|
|
|
|
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]:
|
2011-12-15 14:21:16 +05:30
|
|
|
libPath = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
|
|
|
if os.path.exists(libPath): return libPath
|
|
|
|
else: continue
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
2012-01-18 15:11:10 +05:30
|
|
|
#--------------------------
|
|
|
|
def toolsPath(self,rootRelation = '',release = ''):
|
|
|
|
#--------------------------
|
|
|
|
import os,damask.environment
|
|
|
|
|
2014-01-17 03:10:54 +05:30
|
|
|
MSCpath = damask.environment.Environment(rootRelation).options['MSC_ROOT']
|
2012-01-18 15:11:10 +05:30
|
|
|
|
|
|
|
if len(release) == 0: release = self.version(rootRelation)
|
|
|
|
path = '%s/marc%s/tools'%(MSCpath,release)
|
|
|
|
if os.path.exists(path): return path
|
|
|
|
else: return ''
|
|
|
|
|
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
#--------------------------
|
|
|
|
def submit_job(self,
|
|
|
|
#--------------------------
|
|
|
|
rootRelation = '',
|
2012-01-18 15:11:10 +05:30
|
|
|
release = '',
|
|
|
|
model = 'model',
|
|
|
|
job = 'job1',
|
|
|
|
logfile = None,
|
|
|
|
compile = False,
|
2013-08-08 14:42:44 +05:30
|
|
|
optimization ='',
|
|
|
|
openMP = False
|
2012-01-18 15:11:10 +05:30
|
|
|
):
|
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
import os,damask.environment
|
2012-01-18 15:11:10 +05:30
|
|
|
import subprocess,shlex,shutil
|
2011-12-15 14:21:16 +05:30
|
|
|
|
2012-01-18 15:11:10 +05:30
|
|
|
if len(release) == 0: release = self.version(rootRelation)
|
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
damaskEnv = damask.environment.Environment(rootRelation)
|
2012-01-18 15:11:10 +05:30
|
|
|
|
2013-08-06 15:18:57 +05:30
|
|
|
user = os.path.join(damaskEnv.relPath('code/'),'DAMASK_marc')
|
2012-01-18 15:11:10 +05:30
|
|
|
|
|
|
|
# Define options [see Marc Installation and Operation Guide, pp 23]
|
2014-04-14 21:48:08 +05:30
|
|
|
if int(release[0:4]) >= 2013:
|
2013-08-08 23:40:58 +05:30
|
|
|
script = 'run_damask%s'%({False:'',True:'_'}[optimization!='' or openMP])
|
|
|
|
script = script+'%s%s'%({False:'',True:optimization}[optimization!=''],{False:'',True:'mp'}[openMP])
|
2013-08-08 14:42:44 +05:30
|
|
|
else:
|
|
|
|
script = 'run_marc'
|
|
|
|
|
|
|
|
cmd = os.path.join(self.toolsPath(rootRelation,release),script) + \
|
2012-01-18 15:11:10 +05:30
|
|
|
' -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
|
|
|
|
|
2013-09-19 01:01:27 +05:30
|
|
|
print('job submission with%s compilation: %s'%({False:'out',True:''}[compile],user))
|
2012-01-26 20:56:21 +05:30
|
|
|
if logfile:
|
|
|
|
log = open(logfile, 'w')
|
2011-12-15 14:21:16 +05:30
|
|
|
print(cmd)
|
2012-01-26 20:56:21 +05:30
|
|
|
self.p = subprocess.Popen(shlex.split(cmd),stdout = log,stderr = subprocess.STDOUT)
|
|
|
|
log.close()
|
2011-12-15 14:21:16 +05:30
|
|
|
self.p.wait()
|
|
|
|
|
|
|
|
#--------------------------
|
|
|
|
def exit_number_from_outFile(self,outFile=None):
|
|
|
|
#--------------------------
|
|
|
|
import string
|
2012-01-18 15:11:10 +05:30
|
|
|
exitnumber = -1
|
2011-12-15 14:21:16 +05:30
|
|
|
fid_out = open(outFile,'r')
|
|
|
|
for ln in fid_out:
|
|
|
|
if (string.find(ln,'tress iteration') is not -1):
|
2013-09-19 01:01:27 +05:30
|
|
|
print(ln)
|
2011-12-15 14:21:16 +05:30
|
|
|
elif (string.find(ln,'Exit number') is not -1):
|
|
|
|
substr = ln[string.find(ln,'Exit number'):len(ln)]
|
2012-01-18 15:11:10 +05:30
|
|
|
exitnumber = int(substr[12:16])
|
|
|
|
|
2014-01-17 03:05:51 +05:30
|
|
|
fid_out.close()
|
2012-01-18 15:11:10 +05:30
|
|
|
return exitnumber
|