renamed MSC_TOOLS.library_paths to libraryPath, since only single string is returned
This commit is contained in:
parent
21fcd0357e
commit
e8f5996a96
179
lib/msc_tools.py
179
lib/msc_tools.py
|
@ -1,40 +1,83 @@
|
||||||
class MSC_TOOLS():
|
class MSC_TOOLS():
|
||||||
import os,string
|
import os,string
|
||||||
|
|
||||||
releases = { \
|
releases = { \
|
||||||
'2010.2':['linux64',''],
|
'2010.2':['linux64',''],
|
||||||
'2010': ['linux64',''],
|
'2010': ['linux64',''],
|
||||||
'2008r1':[''],
|
'2008r1':[''],
|
||||||
'2007r1':[''],
|
'2007r1':[''],
|
||||||
'2005r3':[''],
|
'2005r3':[''],
|
||||||
}
|
}
|
||||||
|
|
||||||
def library_paths(self,callerPath='',libRelation=''):
|
#--------------------------
|
||||||
import os
|
def version(self,callerPath='',rootRelation=''):
|
||||||
|
#--------------------------
|
||||||
|
import os
|
||||||
|
|
||||||
if os.getenv('DAMASK_ROOT'): DamaskRoot = os.getenv('DAMASK_ROOT')
|
if os.getenv('DAMASK_ROOT'): DamaskRoot = os.getenv('DAMASK_ROOT')
|
||||||
else: DamaskRoot = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(callerPath)),libRelation))
|
else: DamaskRoot = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(callerPath)),rootRelation))
|
||||||
|
|
||||||
thePath = ''
|
try: # check for MSC.Mentat installation location
|
||||||
try: # check for MSC.Mentat installation location
|
file = open(os.path.join(DamaskRoot,'lib/pathinfo'))
|
||||||
file = open(os.path.join(DamaskRoot,'lib/pathinfo'))
|
for line in file.readlines():
|
||||||
for line in file.readlines():
|
if line.split()[0].lower() == 'msc': MSCpath = os.path.normpath(line.split()[1])
|
||||||
if line.split()[0].lower() == 'msc': MSCpath = os.path.normpath(line.split()[1])
|
file.close()
|
||||||
file.close()
|
except:
|
||||||
except:
|
MSCpath = '/msc'
|
||||||
MSCpath = '/msc'
|
|
||||||
|
|
||||||
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)
|
libPath = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
||||||
if os.path.exists(libPath):
|
if os.path.exists(libPath): return release
|
||||||
thePath = libPath
|
else: continue
|
||||||
return thePath
|
|
||||||
else:
|
return ''
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
def submit_job(self,
|
#--------------------------
|
||||||
|
def libraryPath(self,callerPath='',rootRelation=''):
|
||||||
|
#--------------------------
|
||||||
|
import os
|
||||||
|
|
||||||
|
if os.getenv('DAMASK_ROOT'): DamaskRoot = os.getenv('DAMASK_ROOT')
|
||||||
|
else: DamaskRoot = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(callerPath)),rootRelation))
|
||||||
|
|
||||||
|
try: # check for MSC.Mentat installation location
|
||||||
|
file = open(os.path.join(DamaskRoot,'lib/pathinfo'))
|
||||||
|
for line in file.readlines():
|
||||||
|
if line.split()[0].lower() == 'msc': MSCpath = os.path.normpath(line.split()[1])
|
||||||
|
file.close()
|
||||||
|
except:
|
||||||
|
MSCpath = '/msc'
|
||||||
|
|
||||||
|
for release,subdirs in sorted(self.releases.items(),reverse=True):
|
||||||
|
for subdir in subdirs:
|
||||||
|
libPath = '%s/mentat%s/shlib/%s'%(MSCpath,release,subdir)
|
||||||
|
if os.path.exists(libPath): return libPath
|
||||||
|
else: continue
|
||||||
|
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------
|
||||||
|
def geometry_create (self,inputFile):
|
||||||
|
#--------------------------
|
||||||
|
'''
|
||||||
|
Build nodal coordinates and element connectivity from MSC.Marc input file.
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------
|
||||||
|
def geometry_deform (self,vtkFile,ASCIItable,displacementHeader):
|
||||||
|
#--------------------------
|
||||||
|
'''
|
||||||
|
Alter nodal coordinates in existing VTK file by displacements given in ASCIItable.
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------
|
||||||
|
def submit_job(self,
|
||||||
|
#--------------------------
|
||||||
run_marc_path='/msc/marc2010/tools/',
|
run_marc_path='/msc/marc2010/tools/',
|
||||||
subroutine_dir=None,
|
subroutine_dir=None,
|
||||||
subroutine_name='DAMASK_marc2010',
|
subroutine_name='DAMASK_marc2010',
|
||||||
|
@ -45,45 +88,47 @@ class MSC_TOOLS():
|
||||||
#IOdir='',
|
#IOdir='',
|
||||||
host=[]
|
host=[]
|
||||||
):
|
):
|
||||||
import os
|
import os
|
||||||
import subprocess, shlex
|
import subprocess, shlex
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
if subroutine_dir is None:
|
if subroutine_dir is None:
|
||||||
subroutine_dir=os.getenv('DAMASK_ROOT')+'/code/'
|
subroutine_dir=os.getenv('DAMASK_ROOT')+'/code/'
|
||||||
# Define all options [see Marc Installation and Operation Guide, pp 23]
|
# Define all options [see Marc Installation and Operation Guide, pp 23]
|
||||||
run_marc=run_marc_path+'run_marc'
|
run_marc=run_marc_path+'run_marc'
|
||||||
jid=' -jid '+modelname+'_'+jobname
|
jid=' -jid '+modelname+'_'+jobname
|
||||||
compilation=' -u '+subroutine_dir+subroutine_name+'.f90'+' -save y'
|
compilation=' -u '+subroutine_dir+subroutine_name+'.f90'+' -save y'
|
||||||
options=' -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no'
|
options=' -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no'
|
||||||
cmd=run_marc+jid+options
|
cmd=run_marc+jid+options
|
||||||
|
|
||||||
if compile:
|
if compile:
|
||||||
cmd=cmd+compilation
|
cmd=cmd+compilation
|
||||||
print 'Job submission with compilation.'
|
print 'Job submission with compilation.'
|
||||||
else:
|
else:
|
||||||
shutil.copy2(subroutine_dir+subroutine_name+'.f90','./'+subroutine_name+'.f90')
|
shutil.copy2(subroutine_dir+subroutine_name+'.f90','./'+subroutine_name+'.f90')
|
||||||
shutil.copy2(compiled_dir+subroutine_name+'.marc','./'+subroutine_name+'.marc')
|
shutil.copy2(compiled_dir+subroutine_name+'.marc','./'+subroutine_name+'.marc')
|
||||||
prog=' -prog '+subroutine_name
|
prog=' -prog '+subroutine_name
|
||||||
cmd=cmd+prog
|
cmd=cmd+prog
|
||||||
print 'Job submission without compilation, using %s'%prog
|
print 'Job submission without compilation, using %s'%prog
|
||||||
out=open('out.log','w')
|
out=open('out.log','w')
|
||||||
print(cmd)
|
print(cmd)
|
||||||
#print shlex.split(cmd)
|
#print shlex.split(cmd)
|
||||||
self.p=subprocess.Popen(shlex.split(cmd),stdout=out,stderr=subprocess.STDOUT)
|
self.p=subprocess.Popen(shlex.split(cmd),stdout=out,stderr=subprocess.STDOUT)
|
||||||
self.p.wait()
|
self.p.wait()
|
||||||
out.close()
|
out.close()
|
||||||
|
|
||||||
def exit_number_from_outFile(self,outFile=None):
|
#--------------------------
|
||||||
import string
|
def exit_number_from_outFile(self,outFile=None):
|
||||||
fid_out=open(outFile,'r')
|
#--------------------------
|
||||||
for ln in fid_out:
|
import string
|
||||||
if (string.find(ln,'tress iteration') is not -1):
|
fid_out=open(outFile,'r')
|
||||||
print ln
|
for ln in fid_out:
|
||||||
elif (string.find(ln,'Exit number') is not -1):
|
if (string.find(ln,'tress iteration') is not -1):
|
||||||
substr=ln[string.find(ln,'Exit number'):len(ln)]
|
print ln
|
||||||
exitnumber=substr[12:16]
|
elif (string.find(ln,'Exit number') is not -1):
|
||||||
fid_out.close()
|
substr=ln[string.find(ln,'Exit number'):len(ln)]
|
||||||
return int(exitnumber)
|
exitnumber=substr[12:16]
|
||||||
fid_out.close()
|
fid_out.close()
|
||||||
return -1
|
return int(exitnumber)
|
||||||
|
fid_out.close()
|
||||||
|
return -1
|
||||||
|
|
|
@ -4,7 +4,7 @@ import sys, os, msc_tools, string
|
||||||
from colorsys import *
|
from colorsys import *
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
sys.path.append(msc_tools.MSC_TOOLS().library_paths(sys.argv[0],'../../'))
|
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from py_mentat import *
|
from py_mentat import *
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import sys,os,pwd,math,re,string,msc_tools
|
import sys,os,pwd,math,re,string,msc_tools
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
sys.path.append(msc_tools.MSC_TOOLS().library_paths(sys.argv[0],'../../'))
|
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from py_mentat import *
|
from py_mentat import *
|
||||||
|
|
|
@ -251,7 +251,7 @@ parser.set_defaults(homogenization = 1)
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
sys.path.append(msc_tools.MSC_TOOLS().library_paths(sys.argv[0],'../../'))
|
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from py_mentat import *
|
from py_mentat import *
|
||||||
|
|
|
@ -10,7 +10,7 @@ try: # check for Python Image Lib
|
||||||
except:
|
except:
|
||||||
ImageCapability = False
|
ImageCapability = False
|
||||||
|
|
||||||
sys.path.append(msc_tools.MSC_TOOLS().library_paths(sys.argv[0],'../../'))
|
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||||
|
|
||||||
try: # check for MSC.Mentat Python interface
|
try: # check for MSC.Mentat Python interface
|
||||||
from py_mentat import *
|
from py_mentat import *
|
||||||
|
|
Loading…
Reference in New Issue