finished work on the new installation scheme (if no bugs are found ;))

This commit is contained in:
Martin Diehl 2014-01-14 19:03:41 +00:00
parent 5b0f844e30
commit 01c8c434f7
7 changed files with 116 additions and 147 deletions

View File

@ -12,18 +12,16 @@ source $DAMASK_ROOT/installation/options
if [ "x$DAMASK_NUM_THREADS" != "x" ] if [ "x$DAMASK_NUM_THREADS" != "x" ]
then export DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS then export DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS
fi fi
export FFTWROOT=${FFTWROOT} export FFTW_ROOT=$FFTW_ROOT
LD_NEW=$FFTWROOT/lib LD_NEW=$FFTW_ROOT/lib
if [ "x$LAPACKROOT" != "x" ] if [ "x$LAPACK_ROOT" != "x" ]
then export LAPACKROOT=$LAPACKROOT then LD_NEW=$LD_NEW:$LAPACK_ROOT/lib:$LAPACK_ROOT/lib64
LD_NEW=$LD_NEW:$LAPACKROOT/lib:$LAPACKROOT/lib64
fi fi
if [ "x$ACMLROOT" != "x" ] if [ "x$ACML_ROOT" != "x" ]
then export ACMLROOT=$ACMLROOT then LD_NEW=$LD_NEW:$ACML_ROOT/ifort64_mp/lib:$ACML_ROOT/ifort64/lib:$ACML_ROOT/gfortran64_mp/lib:$ACML_ROOT/gfortran64/lib
LD_NEW=$LD_NEW:$ACMLROOT/ifort64_mp/lib:$ACMLROOT/ifort64/lib:$ACMLROOT/gfortran64_mp/lib:$ACMLROOT/gfortran64/lib
fi fi
if [ "x$IMKLROOT" != "x" ] if [ "x$IMKL_ROOT" != "x" ]
then export IMKLROOT=${IMKLROOT} then LD_NEW=$LD_NEW:$IMKL_ROOT/lib/intel64
fi fi
if [ "x$F90" != "x" ] if [ "x$F90" != "x" ]

View File

@ -467,8 +467,11 @@ endif
tidy: tidy:
@rm -rf *.o @rm -rf *.o
@rm -rf *.mod @rm -rf *.mod
@rm -rf src*
clean: clean:
@rm -rf *.o @rm -rf *.o
@rm -rf *.mod @rm -rf *.mod
@rm -rf *.exe @rm -rf *.exe
@rm -rf src*

26
configure vendored
View File

@ -46,8 +46,8 @@ parser.add_option('--with-blas-lapack-dir', dest='blasdir', type='string',
help='root directory of LAPACK [%default]') help='root directory of LAPACK [%default]')
parser.add_option('--with-blas-type', dest='blastype', type='string', parser.add_option('--with-blas-type', dest='blastype', type='string',
help='type of BLAS/LAPACK library [%default]') help='type of BLAS/LAPACK library [%default]')
parser.add_option('--with-spectral-options', dest='spectraloptions', type='string', parser.add_option('--with-spectral-options', dest='spectraloptions', type='string', action='extend',
help='options for spectral solver [%default]') help='options for spectral solver %default')
compiler = os.getenv('F90') compiler = os.getenv('F90')
if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\ if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\
@ -55,9 +55,10 @@ if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0] stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0]
parser.set_defaults(compiler = compiler) parser.set_defaults(compiler = compiler)
parser.set_defaults(blastype = 'LAPACK') parser.set_defaults(blastype = 'LAPACK')
parser.set_defaults(fftwdir = "/usr/local") parser.set_defaults(fftwdir = '/usr/local')
parser.set_defaults(blasdir = "/usr") parser.set_defaults(blasdir = '/usr')
parser.set_defaults(marcdir = "/msc") parser.set_defaults(marcdir = '/msc')
parser.set_defaults(spectraloptions = [])
(options,filenames) = parser.parse_args() (options,filenames) = parser.parse_args()
@ -73,13 +74,20 @@ with open('installation/options','r') as f:
items = re.split('[= ]',line) items = re.split('[= ]',line)
if items[0] == 'F90': line = '%s=%s\n'%(items[0],options.compiler) if items[0] == 'F90': line = '%s=%s\n'%(items[0],options.compiler)
if items[0] == 'FFTWROOT': line = '%s=%s\n'%(items[0],options.fftwdir) if items[0] == 'FFTW_ROOT': line = '%s=%s\n'%(items[0],options.fftwdir)
if items[0] == 'MSCROOT': line = '%s=%s\n'%(items[0],options.marcdir) if items[0] == 'MSC_ROOT': line = '%s=%s\n'%(items[0],options.marcdir)
for type in blastypes: for blastype in blastypes:
if options.blastype == type and items[0] == '%sROOT'%type: if options.blastype == blastype and items[0] == '%sROOT_'%type:
line = '%s=%s\n'%(items[0],options.blasdir) line = '%s=%s\n'%(items[0],options.blasdir)
for spectralOption in options.spectraloptions:
[key,value] = re.split('[= ]',spectralOption)[0:2]
if key == items[0]:
line = '%s=%s\n'%(items[0],value)
options.spectraloptions.remove(spectralOption)
output.append(line) output.append(line)
for spectralOption in options.spectraloptions:
output.append(spectralOption+'\n')
with open('installation/options','w') as f: with open('installation/options','w') as f:
for line in output: for line in output:

View File

@ -1,102 +1,84 @@
#!/usr/bin/env python #!/usr/bin/env python
# Makes postprocessing routines acessible from everywhere. # compiles fortran code for Python
import os,sys,glob,string,subprocess import os,sys,glob,string,subprocess,shlex
from damask import Environment from damask import Environment
damaskEnv = Environment() damaskEnv = Environment()
baseDir = damaskEnv.relPath('installation/') baseDir = damaskEnv.relPath('installation/')
codeDir = damaskEnv.relPath('code/') codeDir = damaskEnv.relPath('code/')
try: options={}
imklroot = damaskEnv.options['IMKLROOT']
except:
imklroot = os.getenv('IMKLROOT')
if imklroot == None: imklroot == '' # env not set
try: for option in ['IMKL_ROOT','ACML_ROOT','LAPACK_ROOT','FFTW_ROOT','F90']:
acmlroot = damaskEnv.options['ACMLROOT'] try:
except: value = damaskEnv.options[option]
acmlroot = os.getenv('ACMLROOT') except:
if acmlroot == None: acmlroot == '' # env not set value = os.getenv(option)
if value is None: value = '' # env not set
try: options[option]=value
lapackroot = damaskEnv.options['LAPACKROOT']
except:
lapackroot = os.getenv('LAPACKROOT')
if lapackroot == None: lapackroot == '' # env not set
try:
fftwroot = damaskEnv.options['FFTWROOT']
except:
fftwroot = os.getenv('FFTWROOT')
if fftwroot == None: fftwroot == '' # env not set
try:
compiler = damaskEnv.options['F90']
except:
compiler = os.getenv('F90')
if compiler == None: compiler == '' # env not set
compilers = ['ifort','gfortran'] compilers = ['ifort','gfortran']
if compiler not in compilers: if options['F90'] not in compilers:
parser.error('compiler switch "F90" has to be one out of: %s'%(', '.join(compilers))) sys.exit('compiler "F90" (in installation/options or as Shell variable) has to be one out of: %s'%(', '.join(compilers)))
f2py_compiler = { compileCommand = {
'gfortran': 'gnu95 --f90flags="-fPIC -fno-range-check -xf95-cpp-input -std=f2008 -fall-intrinsics -DSpectral -fdefault-real-8 -fdefault-double-8 -DFLOAT=8 -DINT=4 -I${DAMASK_ROOT}/lib"', 'gfortran': 'gnu95 --f90flags="-fPIC -fno-range-check -xf95-cpp-input -std=f2008 -fall-intrinsics'+\
'ifort': 'intelem --f90flags="-fPIC -fpp -stand f08 -diag-disable 5268 -assume byterecl -DSpectral -real-size 64 -integer-size 32 -DFLOAT=8 -DINT=4 -I${DAMASK_ROOT}/lib"', ' -DSpectral -fdefault-real-8 -fdefault-double-8 -DFLOAT=8 -DINT=4 -I%s/lib"'%damaskEnv.rootDir(),
}[compiler] 'ifort': 'intelem --f90flags="-fPIC -fpp -stand f08 -diag-disable 5268 -assume byterecl'+\
' -DSpectral -real-size 64 -integer-size 32 -DFLOAT=8 -DINT=4 -I%s/lib"'%damaskEnv.rootDir(),
}[options['F90']]
# see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html
if options['IMKL_ROOT'] != '' and options['F90'] != 'gfortran':
if imklroot != '' and compiler != 'gfortran': lib_lapack = '-L%s/lib/intel64 -I%s/include -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lm'%(options['IMKL_ROOT'],options['IMKL_ROOT'])
lib_lapack = '-L%s/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5 -lpthread -lm'%(imklroot) elif options['ACML_ROOT'] != '':
elif acmlroot != '': lib_lapack = '-L%s/%s64/lib -lacml'%(options['ACML_ROOT'],options['F90'])
lib_lapack = '-L%s/%s64/lib -lacml'%(acmlroot,compiler)
elif lapackroot != '': elif lapackroot != '':
lib_lapack = '-L%s -llapack'%(lapack) # see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html lib_lapack = '-L%s -llapack'%(options['LAPACK_ROOT'])
execute = { \ os.chdir(codeDir) # needed for compilation with gfortran and f2py
'coreModule' : [ try:
# The following command is used to compile the fortran files and make the functions defined os.remove(os.path.join(damaskEnv.relPath('lib/damask'),'core.so'))
# in damask.core.pyf available for python in the module core.so except OSError, e: ## if failed, report it back to the user ##
# It uses the fortran wrapper f2py that is included in the numpy package to construct the print ("Error when deleting: %s - %s." % (e.filename,e.strerror))
# module core.so out of the fortran code in the f90 files
# For the generation of the pyf file use the following lines:
###########################################################################
#'f2py -h damask.core.pyf' +\
#' --overwrite-signature --no-lower prec.f90 DAMASK_spectral_interface.f90 math.f90 mesh.f90',
###########################################################################
'rm `readlink -f %s`' %(os.path.join(damaskEnv.relPath('lib/damask'),'core.so')), # do this using system remove
'f2py damask.core.pyf' +\
' --build-dir ./' +\
' -c --no-lower --fcompiler=%s'%(f2py_compiler) +\
' %s'%'prec.f90'+\
' %s'%'DAMASK_spectral_interface.f90'+\
' %s'%'IO.f90'+\
' %s'%'libs.f90'+\
' %s'%'numerics.f90'+\
' %s'%'debug.f90'+\
' %s'%'math.f90'+\
' %s'%'FEsolving.f90'+\
' %s'%'mesh.f90'+\
' %s'%'core_quit.f90'+\
' -L%s/lib -lfftw3'%(fftwroot)+\
' %s'%lib_lapack,
'mv %s `readlink -f %s`' %(os.path.join(codeDir,'core.so'),os.path.join(damaskEnv.relPath('lib/damask'),'core.so')), # do this using system remove
]
}
os.chdir(codeDir) # needed for compilation with gfortran and f2py
for tasks in execute: # The following command is used to compile the fortran files and make the functions defined
for cmd in execute[tasks]: # in damask.core.pyf available for python in the module core.so
try: # It uses the fortran wrapper f2py that is included in the numpy package to construct the
print 'executing...:',cmd # module core.so out of the fortran code in the f90 files
os.system(cmd) # For the generation of the pyf file use the following lines:
except: ###########################################################################
print 'failed..!' #'f2py -h damask.core.pyf' +\
pass #' --overwrite-signature --no-lower prec.f90 DAMASK_spectral_interface.f90 math.f90 mesh.f90,...'
###########################################################################
cmd = 'f2py damask.core.pyf' +\
' --build-dir %s'%codeDir +\
' -c --no-lower --fcompiler=%s'%(compileCommand) +\
' prec.f90'+\
' DAMASK_spectral_interface.f90'+\
' IO.f90'+\
' libs.f90'+\
' numerics.f90'+\
' debug.f90'+\
' math.f90'+\
' FEsolving.f90'+\
' mesh.f90'+\
' core_quit.f90'+\
' -L%s/lib -lfftw3'%(options['FFTW_ROOT'])+\
' %s'%lib_lapack
print('Executing: '+cmd)
try:
subprocess.call(shlex.split(cmd))
except subprocess.CalledProcessError:
print('build failed')
except OSError:
print ('f2py not found')
os.rename(os.path.join(codeDir,'core.so'), os.path.join(damaskEnv.relPath('lib/damask'),'core.so'))
modules = glob.glob('*.mod') modules = glob.glob('*.mod')
for module in modules: for module in modules:
@ -108,5 +90,3 @@ try:
with open(damaskEnv.relPath('lib/damask/core.so')) as f: pass with open(damaskEnv.relPath('lib/damask/core.so')) as f: pass
except IOError as e: except IOError as e:
print '*********\n* core.so not found, compilation of core modules was not successful\n*********' print '*********\n* core.so not found, compilation of core modules was not successful\n*********'
sys.exit()
f.close

View File

@ -16,8 +16,8 @@ do
done done
echo "MSC version: $VERSION" echo "MSC version: $VERSION"
if [ "x$MSCROOT" != "x" ] if [ "x$MSC_ROOT" != "x" ]
then INSTALLDIR=$MSCROOT then INSTALLDIR=$MSC_ROOT
fi fi
while [ ! -d "$INSTALLDIR" ] || [ -z "$INSTALLDIR" ] while [ ! -d "$INSTALLDIR" ] || [ -z "$INSTALLDIR" ]
@ -31,16 +31,16 @@ echo "MSC installation path: $INSTALLDIR"
BLASDIR='' BLASDIR=''
BLASTYPE='' BLASTYPE=''
if [ "x$LAPACKROOT" != "x" ] if [ "x$LAPACK_ROOT" != "x" ]
BLASDIR=$LAPACKROOT BLASDIR=$LAPACK_ROOT
BLASTYPE='LAPACK' BLASTYPE='LAPACK'
fi fi
if [ "x$ACMLROOT" != "x" ] if [ "x$ACML_ROOT" != "x" ]
BLASDIR=$ACMLROOT BLASDIR=$ACML_ROOT
BLASTYPE='ACML' BLASTYPE='ACML'
fi fi
if [ "x$IMKLROOT" != "x" ] if [ "x$IMKL_ROOT" != "x" ]
BLASDIR=$IMKLROOT BLASDIR=$IMKL_ROOT
BLASTYPE='IMKL' BLASTYPE='IMKL'
fi fi

View File

@ -1,17 +1,18 @@
# $Id: pathinfo 2176 2013-02-19 13:35:38Z MPIE\p.eisenlohr $ # $Id: pathinfo 2176 2013-02-19 13:35:38Z MPIE\p.eisenlohr $
# possible options are # possible options are
# IMKLROOT base installation directory of Intel Math Kernel Library # IMKL_ROOT base installation directory of Intel Math Kernel Library
# ACMLROOT base installation directory of AMD Core Math Library # ACML_ROOT base installation directory of AMD Core Math Library
# LAPACKROOT base installation directory of (system) LAPACK Library # LAPAC_KROOT base installation directory of (system) LAPACK Library
# MSC base installation directory of MSC.Marc/Mentat # MSC_ROOT base installation directory of MSC.Marc/Mentat
# FFTWROOT base installation directory of Fastest Fourier Transform in the West library # FFTW_ROOT base installation directory of Fastest Fourier Transform in the West library
# Do NOT add any trailing /lib/ to the end # Do NOT add any trailing /lib/ to the end
# of the base installation path---this will be done automatically # of the base installation path---this will be done automatically
FFTWROOT=/usr/local FFTW_ROOT=
LAPACKROOT=/usr LAPACK_ROOT=
ACMLROOT= ACML_ROOT=
IMKLROOT= IMKL_ROOT=
F90=gfortran MSC_ROOT=
MSCROOT=/msc F90=
DAMASK_NUM_THREADS=2 DAMASK_NUM_THREADS=2

View File

@ -10,8 +10,8 @@ class Environment():
def __init__(self,rootRelation = '.'): def __init__(self,rootRelation = '.'):
self.rootRelation = rootRelation self.rootRelation = rootRelation
self.pathInfo = {} self.options = {}
self.get_pathInfo() self.get_options()
def relPath(self,relative = '.'): def relPath(self,relative = '.'):
return os.path.join(self.rootDir(),relative) return os.path.join(self.rootDir(),relative)
@ -32,23 +32,6 @@ class Environment():
damask_bin = os.getenv('DAMASK_BIN') damask_bin = os.getenv('DAMASK_BIN')
if damask_bin == '' or damask_bin == None: damask_bin = self.relPath('bin/') if damask_bin == '' or damask_bin == None: damask_bin = self.relPath('bin/')
return damask_bin return damask_bin
def get_pathInfo(self):
try: # check for user-defined pathinfo
file = open(self.relPath('lib/pathinfo'))
content = map(lambda string: string.strip(),file.readlines())
file.close()
for line in content:
if not (line.startswith('#') or line == ''):
items = line.split() + ['','']
if items[1] == '': # nothing specified
self.pathInfo[items[0].lower()] = ''
elif items[1].startswith(('/','$')): # absolute path specified ($shellVar is considered absolute)
self.pathInfo[items[0].lower()] = items[1]
else: # path relative to DAMASK_ROOT/lib
self.pathInfo[items[0].lower()] = os.path.normpath(os.path.join(self.relPath('lib/'),items[1]))
except:
pass
def get_options(self): def get_options(self):
try: # check for user-defined pathinfo try: # check for user-defined pathinfo
@ -58,12 +41,8 @@ class Environment():
for line in content: for line in content:
if not (line.startswith('#') or line == ''): if not (line.startswith('#') or line == ''):
items = line.split('=') + ['',''] items = line.split('=') + ['','']
if items[1] == '': # nothing specified if items[1] != '': # nothing specified
self.pathInfo[items[0].lower()] = '' self.options[items[0].upper()] = items[1]
elif items[1].startswith(('/','$')): # absolute path specified ($shellVar is considered absolute)
self.pathInfo[items[0].lower()] = items[1]
else: # path relative to DAMASK_ROOT/lib
self.pathInfo[items[0].lower()] = os.path.normpath(os.path.join(self.relPath('lib/'),items[1]))
except: except:
pass pass