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:
|
for arch in architectures:
|
||||||
me = architectures[arch]
|
me = architectures[arch]
|
||||||
try:
|
try:
|
||||||
parentFile = open(wd+os.sep+me['parent'])
|
parentFile = open(basedir+os.sep+me['parent'])
|
||||||
parentContent = parentFile.readlines()
|
parentContent = parentFile.readlines()
|
||||||
parentFile.close()
|
parentFile.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -24,17 +30,17 @@ for arch in architectures:
|
||||||
|
|
||||||
|
|
||||||
for version in me['versions'][1:]:
|
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:
|
for line in parentContent:
|
||||||
childFile.write(line.replace(me['versions'][0],version))
|
childFile.write(line.replace(me['versions'][0],version))
|
||||||
childFile.close()
|
childFile.close()
|
||||||
|
|
||||||
# changing dirs in make file
|
# changing dirs in make file
|
||||||
damask_variables = damask_tools.DAMASK_TOOLS()
|
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()
|
content = makefile.readlines()
|
||||||
makefile.close()
|
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:
|
for line in content:
|
||||||
if line.startswith('FFTWPATH'):
|
if line.startswith('FFTWPATH'):
|
||||||
line='FFTWPATH =%s\n'%(damask_variables.pathInfo['fftw'])
|
line='FFTWPATH =%s\n'%(damask_variables.pathInfo['fftw'])
|
||||||
|
@ -48,9 +54,21 @@ makefile.close()
|
||||||
# compiling spectral code
|
# compiling spectral code
|
||||||
if raw_input("Do you want to compile the spectral code now? (y/n) ") is 'y' or 'Y':
|
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) ")
|
compiler_switches = raw_input("Please give compiling switches (Enter to use default) ")
|
||||||
os.system('make --directory %s clean'%(wd))
|
os.system('make --directory %s clean'%(basedir))
|
||||||
print compiler_switches
|
os.system('make --directory %s %s'%(basedir,compiler_switches))
|
||||||
os.system('make --directory %s %s'%(wd,compiler_switches))
|
|
||||||
|
|
||||||
if '--clean' in [s.lower() for s in sys.argv]:
|
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 = '.'):
|
def __init__(self,rootRelation = '.'):
|
||||||
self.pathInfo = {\
|
self.pathInfo = {\
|
||||||
'acml': './acml4.4.0',
|
'acml': '/opt/acml4.4.0',
|
||||||
'fftw': './fftw',
|
'fftw': '.',
|
||||||
'msc': '/msc',
|
'msc': '/msc',
|
||||||
}
|
}
|
||||||
self.get_pathInfo(rootRelation)
|
self.get_pathInfo(rootRelation)
|
||||||
|
|
||||||
|
def relPath(self,relative = '.'):
|
||||||
|
return os.path.join(self.rootDir(),relative)
|
||||||
|
|
||||||
def rootDir(self,rootRelation = '.'): #getting pathinfo
|
def rootDir(self,rootRelation = '.'): #getting pathinfo
|
||||||
damask_root = os.getenv('DAMASK_ROOT')
|
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)
|
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
|
def binDir(self,rootRelation = '.'): #getting pathinfo
|
||||||
damask_bin = os.getenv('DAMASK_BIN')
|
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
|
return damask_bin
|
||||||
|
|
||||||
def get_pathInfo(self,rootRelation = '.'): #getting pathinfo
|
def get_pathInfo(self,rootRelation = '.'): #getting pathinfo
|
||||||
damask_root = self.rootDir(rootRelation)
|
damask_root = self.rootDir(rootRelation)
|
||||||
|
|
||||||
try: # check for user-defined pathinfo
|
try: # check for user-defined pathinfo
|
||||||
file = open(os.path.join(damask_root,'lib/pathinfo'))
|
file = open(self.relPath('lib/pathinfo'))
|
||||||
content = file.readlines()
|
content = file.readlines()
|
||||||
file.close()
|
file.close()
|
||||||
for line in content:
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -40,9 +43,7 @@ class DAMASK_TOOLS():
|
||||||
import os
|
import os
|
||||||
if os.getenv('DAMASK_ROOT') is None:
|
if os.getenv('DAMASK_ROOT') is None:
|
||||||
print('No DAMASK_ROOT environment variable, did you run DAMASK/installation/setup_shellrc?')
|
print('No DAMASK_ROOT environment variable, did you run DAMASK/installation/setup_shellrc?')
|
||||||
sys.exit(1)
|
return os.getenv('DAMASK_ROOT') != None
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,16 +46,16 @@ parser.set_defaults(compiler = 'ifort')
|
||||||
#translating name of compiler for use with f2py and setting subdirname of acml
|
#translating name of compiler for use with f2py and setting subdirname of acml
|
||||||
if options.compiler == 'gfortran':
|
if options.compiler == 'gfortran':
|
||||||
f2py_compiler='gnu95 --f90flags="-fno-range-check"'
|
f2py_compiler='gnu95 --f90flags="-fno-range-check"'
|
||||||
acml_subdir='ifort64/lib'
|
|
||||||
else:
|
else:
|
||||||
f2py_compiler='intelem'
|
f2py_compiler='intelem'
|
||||||
acml_subdir='ifort64/lib'
|
|
||||||
|
acml_subdir='%s64/lib'%options.compiler
|
||||||
|
|
||||||
|
|
||||||
#getting pathinfo
|
#getting pathinfo
|
||||||
damask_variables = damask_tools.DAMASK_TOOLS()
|
damask_variables = damask_tools.DAMASK_TOOLS()
|
||||||
baseDir = os.path.join(damask_variables.rootDir(),'processing/')
|
baseDir = damask_variables.relPath('processing/')
|
||||||
codeDir = os.path.join(damask_variables.rootDir(),'code/')
|
codeDir = damask_variables.relPath('code/')
|
||||||
|
|
||||||
#define ToDo list
|
#define ToDo list
|
||||||
bin_link = { \
|
bin_link = { \
|
||||||
|
@ -101,20 +101,20 @@ compile = { \
|
||||||
|
|
||||||
execute = { \
|
execute = { \
|
||||||
'postMath' : [
|
'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
|
# 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
|
# 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
|
# module postprocessingMath.so out of the fortran code postprocessingMath.f90
|
||||||
# for the generation of the pyf file:
|
# for the generation of the pyf file:
|
||||||
#f2py -m DAMASK -h DAMASK.pyf --overwrite-signature ../../code/math.f90 \
|
#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) +\
|
'-c --fcompiler=%s '%(f2py_compiler) +\
|
||||||
'%sDAMASK2Python_helper.f90 ' %(codeDir)+\
|
'%s ' %(os.path.join(codeDir,'DAMASK2Python_helper.f90'))+\
|
||||||
'%smath.f90 ' %(codeDir)+\
|
'%s ' %(os.path.join(codeDir,'math.f90'))+\
|
||||||
'%s/libfftw3.a ' %(damask_variables.pathInfo['fftw'])+\
|
'%s ' %(os.path.join(damask_variables.pathInfo['fftw'],'libfftw3.a'))+\
|
||||||
'%s/%s/libacml.a' %(damask_variables.pathInfo['acml'],acml_subdir),
|
'%s' %(os.path.join(damask_variables.pathInfo['acml'],acml_subdir,'libacml.a'),
|
||||||
'mv %sDAMASK.so %s/.' %(codeDir,os.path.join(damask_variables.rootDir(),'lib/')),
|
'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 tasks in execute:
|
||||||
for cmd in execute[tasks]:
|
for cmd in execute[tasks]:
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
os.chdir(os.path.join(damask_variables.rootDir(),'processing/setup/'))
|
os.chdir(damask_variables.relPath('processing/setup/'))
|
||||||
|
|
||||||
modules = glob.glob('*.mod')
|
modules = glob.glob('*.mod')
|
||||||
for module in modules:
|
for module in modules:
|
||||||
|
|
Loading…
Reference in New Issue