2014-04-02 00:11:14 +05:30
|
|
|
# -*- coding: UTF-8 no BOM -*-
|
|
|
|
|
2011-12-22 16:00:25 +05:30
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
from .solver import Solver
|
|
|
|
|
|
|
|
|
|
|
|
class Marc(Solver):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.solver = 'Marc'
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------
|
2016-07-16 13:06:15 +05:30
|
|
|
def version(self):
|
2018-11-16 01:46:13 +05:30
|
|
|
import damask.environment
|
2011-12-15 14:21:16 +05:30
|
|
|
|
2018-11-16 01:46:13 +05:30
|
|
|
return damask.environment.Environment().options['MARC_VERSION']
|
2011-12-15 14:21:16 +05:30
|
|
|
|
|
|
|
|
|
|
|
#--------------------------
|
2018-11-16 01:46:13 +05:30
|
|
|
def libraryPath(self,release = ''):
|
2011-12-15 14:21:16 +05:30
|
|
|
import os,damask.environment
|
|
|
|
|
2018-11-16 01:46:13 +05:30
|
|
|
MSCpath = damask.environment.Environment().options['MSC_ROOT']
|
|
|
|
if len(release) == 0: release = self.version()
|
2011-12-15 14:21:16 +05:30
|
|
|
|
2018-11-16 01:46:13 +05:30
|
|
|
path = '{}/mentat{}/shlib/linux64'.format(MSCpath,release)
|
|
|
|
|
|
|
|
return path if os.path.exists(path) else ''
|
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
|
2012-01-18 15:11:10 +05:30
|
|
|
#--------------------------
|
2016-07-16 13:06:15 +05:30
|
|
|
def toolsPath(self,release = ''):
|
2012-01-18 15:11:10 +05:30
|
|
|
import os,damask.environment
|
|
|
|
|
2016-07-16 13:06:15 +05:30
|
|
|
MSCpath = damask.environment.Environment().options['MSC_ROOT']
|
|
|
|
if len(release) == 0: release = self.version()
|
2018-11-16 01:46:13 +05:30
|
|
|
|
2012-01-18 15:11:10 +05:30
|
|
|
path = '%s/marc%s/tools'%(MSCpath,release)
|
2018-11-16 01:46:13 +05:30
|
|
|
|
|
|
|
return path if os.path.exists(path) else ''
|
2012-01-18 15:11:10 +05:30
|
|
|
|
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
#--------------------------
|
|
|
|
def submit_job(self,
|
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 ='',
|
2012-01-18 15:11:10 +05:30
|
|
|
):
|
|
|
|
|
2011-12-15 14:21:16 +05:30
|
|
|
import os,damask.environment
|
2016-03-02 03:32:47 +05:30
|
|
|
import subprocess,shlex
|
2011-12-15 14:21:16 +05:30
|
|
|
|
2016-07-16 13:06:15 +05:30
|
|
|
if len(release) == 0: release = self.version()
|
|
|
|
damaskEnv = damask.environment.Environment()
|
2012-01-18 15:11:10 +05:30
|
|
|
|
2014-05-09 16:59:35 +05:30
|
|
|
if compile:
|
2017-02-09 00:02:20 +05:30
|
|
|
if os.path.isfile(os.path.join(damaskEnv.relPath('src/'),'DAMASK_marc%s.f90'%release)):
|
|
|
|
user = os.path.join(damaskEnv.relPath('src/'),'DAMASK_marc%s'%release)
|
2014-05-09 16:59:35 +05:30
|
|
|
else:
|
2017-02-09 00:02:20 +05:30
|
|
|
if os.path.isfile(os.path.join(damaskEnv.relPath('src/'),'DAMASK_marc%s.marc'%release)):
|
|
|
|
user = os.path.join(damaskEnv.relPath('src/'),'DAMASK_marc%s'%release)
|
2012-01-18 15:11:10 +05:30
|
|
|
|
|
|
|
# Define options [see Marc Installation and Operation Guide, pp 23]
|
2018-11-14 16:55:31 +05:30
|
|
|
script = 'run_damask_%smp'%({False:'',True:optimization}[optimization!=''])
|
2013-08-08 14:42:44 +05:30
|
|
|
|
2016-07-16 13:06:15 +05:30
|
|
|
cmd = os.path.join(self.toolsPath(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()
|
2018-11-16 10:45:23 +05:30
|
|
|
line.p.wait()
|
2011-12-15 14:21:16 +05:30
|
|
|
|
|
|
|
#--------------------------
|
|
|
|
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')
|
2018-11-16 10:45:23 +05:30
|
|
|
for line in fid_out:
|
|
|
|
if (string.find(line,'tress iteration') is not -1):
|
|
|
|
print(line)
|
|
|
|
elif (string.find(line,'Exit number') is not -1):
|
|
|
|
substr = line[string.find(line,'Exit number'):len(line)]
|
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
|