introduced new damask_tools method "relPath" and adopted it in setup_processing.py and setup_code.py
This commit is contained in:
parent
ea0fe7b406
commit
2ceb78c337
|
@ -10,12 +10,18 @@ architectures = {
|
|||
},
|
||||
}
|
||||
|
||||
wd = os.path.join(os.path.dirname(sys.argv[0]),'..')
|
||||
bin_link = { \
|
||||
'' : [
|
||||
'DAMASK_spectral.exe',
|
||||
],
|
||||
}
|
||||
|
||||
basedir = damask_variables.relPath('code/')
|
||||
|
||||
for arch in architectures:
|
||||
me = architectures[arch]
|
||||
try:
|
||||
parentFile = open(wd+os.sep+me['parent'])
|
||||
parentFile = open(basedir+os.sep+me['parent'])
|
||||
parentContent = parentFile.readlines()
|
||||
parentFile.close()
|
||||
except IOError:
|
||||
|
@ -24,17 +30,17 @@ for arch in architectures:
|
|||
|
||||
|
||||
for version in me['versions'][1:]:
|
||||
childFile = open(wd+os.sep+version.join(os.path.splitext(me['parent'])),'w')
|
||||
childFile = open(basedir+os.sep+version.join(os.path.splitext(me['parent'])),'w')
|
||||
for line in parentContent:
|
||||
childFile.write(line.replace(me['versions'][0],version))
|
||||
childFile.close()
|
||||
|
||||
# changing dirs in make file
|
||||
damask_variables = damask_tools.DAMASK_TOOLS()
|
||||
makefile = open(os.path.join(damask_variables.rootDir(),'code/makefile'))
|
||||
makefile = open(os.path.join(basedir,'makefile'))
|
||||
content = makefile.readlines()
|
||||
makefile.close()
|
||||
makefile = open(os.path.join(damask_variables.rootDir(),'code/makefile'),'w')
|
||||
makefile = open(os.path.join(basedir,'makefile'),'w')
|
||||
for line in content:
|
||||
if line.startswith('FFTWPATH'):
|
||||
line='FFTWPATH =%s\n'%(damask_variables.pathInfo['fftw'])
|
||||
|
@ -48,9 +54,21 @@ makefile.close()
|
|||
# compiling spectral code
|
||||
if raw_input("Do you want to compile the spectral code now? (y/n) ") is 'y' or 'Y':
|
||||
compiler_switches = raw_input("Please give compiling switches (Enter to use default) ")
|
||||
os.system('make --directory %s clean'%(wd))
|
||||
print compiler_switches
|
||||
os.system('make --directory %s %s'%(wd,compiler_switches))
|
||||
os.system('make --directory %s clean'%(basedir))
|
||||
os.system('make --directory %s %s'%(basedir,compiler_switches))
|
||||
|
||||
if '--clean' in [s.lower() for s in sys.argv]:
|
||||
os.system('make --directory %s clean'%wd)
|
||||
os.system('make --directory %s clean'%basedir)
|
||||
|
||||
|
||||
for dir in bin_link:
|
||||
for file in bin_link[dir]:
|
||||
src = os.path.abspath(os.path.join(baseDir,dir,file))
|
||||
if (file == ''):
|
||||
sym_link = os.path.abspath(os.path.join(damask_variables.binDir(),dir))
|
||||
else:
|
||||
sym_link = os.path.abspath(os.path.join(damask_variables.binDir(),os.path.splitext(file)[0]))
|
||||
print sym_link,'-->',src
|
||||
if os.path.lexists(sym_link):
|
||||
os.remove(sym_link)
|
||||
os.symlink(src,sym_link)
|
||||
|
|
|
@ -8,12 +8,15 @@ class DAMASK_TOOLS():
|
|||
|
||||
def __init__(self,rootRelation = '.'):
|
||||
self.pathInfo = {\
|
||||
'acml': './acml4.4.0',
|
||||
'fftw': './fftw',
|
||||
'acml': '/opt/acml4.4.0',
|
||||
'fftw': '.',
|
||||
'msc': '/msc',
|
||||
}
|
||||
self.get_pathInfo(rootRelation)
|
||||
|
||||
def relPath(self,relative = '.'):
|
||||
return os.path.join(self.rootDir(),relative)
|
||||
|
||||
def rootDir(self,rootRelation = '.'): #getting pathinfo
|
||||
damask_root = os.getenv('DAMASK_ROOT')
|
||||
if damask_root == '' or damask_root == None: damask_root = os.path.join(os.path.dirname(sys.argv[0]),rootRelation)
|
||||
|
@ -21,18 +24,18 @@ class DAMASK_TOOLS():
|
|||
|
||||
def binDir(self,rootRelation = '.'): #getting pathinfo
|
||||
damask_bin = os.getenv('DAMASK_BIN')
|
||||
if damask_bin == '' or damask_bin == None: damask_bin = os.path.join(self.rootDir(),'bin/')
|
||||
if damask_bin == '' or damask_bin == None: damask_bin = self.relPath('bin/')
|
||||
return damask_bin
|
||||
|
||||
def get_pathInfo(self,rootRelation = '.'): #getting pathinfo
|
||||
damask_root = self.rootDir(rootRelation)
|
||||
|
||||
try: # check for user-defined pathinfo
|
||||
file = open(os.path.join(damask_root,'lib/pathinfo'))
|
||||
file = open(self.relPath('lib/pathinfo'))
|
||||
content = file.readlines()
|
||||
file.close()
|
||||
for line in content:
|
||||
self.pathInfo[line.split()[0].lower()] = os.path.normpath(os.path.join(damask_root,'lib/',line.split()[1]))
|
||||
self.pathInfo[line.split()[0].lower()] = os.path.normpath(os.path.join(self.relPath('lib/'),line.split()[1]))
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -40,9 +43,7 @@ class DAMASK_TOOLS():
|
|||
import os
|
||||
if os.getenv('DAMASK_ROOT') is None:
|
||||
print('No DAMASK_ROOT environment variable, did you run DAMASK/installation/setup_shellrc?')
|
||||
sys.exit(1)
|
||||
else:
|
||||
return True
|
||||
return os.getenv('DAMASK_ROOT') != None
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -46,16 +46,16 @@ parser.set_defaults(compiler = 'ifort')
|
|||
#translating name of compiler for use with f2py and setting subdirname of acml
|
||||
if options.compiler == 'gfortran':
|
||||
f2py_compiler='gnu95 --f90flags="-fno-range-check"'
|
||||
acml_subdir='ifort64/lib'
|
||||
else:
|
||||
f2py_compiler='intelem'
|
||||
acml_subdir='ifort64/lib'
|
||||
|
||||
acml_subdir='%s64/lib'%options.compiler
|
||||
|
||||
|
||||
#getting pathinfo
|
||||
damask_variables = damask_tools.DAMASK_TOOLS()
|
||||
baseDir = os.path.join(damask_variables.rootDir(),'processing/')
|
||||
codeDir = os.path.join(damask_variables.rootDir(),'code/')
|
||||
baseDir = damask_variables.relPath('processing/')
|
||||
codeDir = damask_variables.relPath('code/')
|
||||
|
||||
#define ToDo list
|
||||
bin_link = { \
|
||||
|
@ -101,20 +101,20 @@ compile = { \
|
|||
|
||||
execute = { \
|
||||
'postMath' : [
|
||||
'rm %slib/DAMASK.so' %(os.path.join(damask_variables.rootDir(),'lib/')),
|
||||
'rm %s'%(os.path.join(damask_variables.relPath('lib/'),'DAMASK.so')),
|
||||
# The following command is used to compile math.f90 and make the functions defined in DAMASK_math.pyf
|
||||
# avialable for python in the module DAMASK_math.so
|
||||
# available for python in the module DAMASK_math.so
|
||||
# It uses the fortran wrapper f2py that is included in the numpy package to construct the
|
||||
# module postprocessingMath.so out of the fortran code postprocessingMath.f90
|
||||
# for the generation of the pyf file:
|
||||
#f2py -m DAMASK -h DAMASK.pyf --overwrite-signature ../../code/math.f90 \
|
||||
'f2py %sDAMASK.pyf '%(codeDir) +\
|
||||
'f2py %s '%(os.path.join(codeDir,'DAMASK.pyf')) +\
|
||||
'-c --fcompiler=%s '%(f2py_compiler) +\
|
||||
'%sDAMASK2Python_helper.f90 ' %(codeDir)+\
|
||||
'%smath.f90 ' %(codeDir)+\
|
||||
'%s/libfftw3.a ' %(damask_variables.pathInfo['fftw'])+\
|
||||
'%s/%s/libacml.a' %(damask_variables.pathInfo['acml'],acml_subdir),
|
||||
'mv %sDAMASK.so %s/.' %(codeDir,os.path.join(damask_variables.rootDir(),'lib/')),
|
||||
'%s ' %(os.path.join(codeDir,'DAMASK2Python_helper.f90'))+\
|
||||
'%s ' %(os.path.join(codeDir,'math.f90'))+\
|
||||
'%s ' %(os.path.join(damask_variables.pathInfo['fftw'],'libfftw3.a'))+\
|
||||
'%s' %(os.path.join(damask_variables.pathInfo['acml'],acml_subdir,'libacml.a'),
|
||||
'mv %s %s' %(os.path.join(codeDir,'DAMASK.so'),damask_variables.relPath('lib/')),
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ os.chdir(codeDir) # needed for compilation with gfortran and f
|
|||
for tasks in execute:
|
||||
for cmd in execute[tasks]:
|
||||
os.system(cmd)
|
||||
os.chdir(os.path.join(damask_variables.rootDir(),'processing/setup/'))
|
||||
os.chdir(damask_variables.relPath('processing/setup/'))
|
||||
|
||||
modules = glob.glob('*.mod')
|
||||
for module in modules:
|
||||
|
|
Loading…
Reference in New Issue