some more work on the consistent installation scheme, fixed bug in Makefile

This commit is contained in:
Martin Diehl 2014-01-11 19:13:02 +00:00
parent 0fd9fff7ae
commit 80da1c529e
4 changed files with 78 additions and 105 deletions

View File

@ -1,6 +1,6 @@
# sets up an environment for DAMASK on bash # sets up an environment for DAMASK on bash
# usage: source DAMASK_env.sh # usage: source DAMASK_env.sh
source ./installation/options
if [ "$OSTYPE" == "linux-gnu" ] if [ "$OSTYPE" == "linux-gnu" ]
then LOCATION=$(readlink -f "`dirname $BASH_SOURCE`") then LOCATION=$(readlink -f "`dirname $BASH_SOURCE`")
else else
@ -9,6 +9,7 @@ else
fi fi
export DAMASK_ROOT=${LOCATION} export DAMASK_ROOT=${LOCATION}
export DAMASK_NUM_THREADS=2 export DAMASK_NUM_THREADS=2
source $DAMASK_ROOT/installation/options
export FFTWROOT=${FFTWROOT} export FFTWROOT=${FFTWROOT}
LD_NEW=$FFTWROOT/lib LD_NEW=$FFTWROOT/lib
if [ "x$LAPACKROOT" != "x" ] if [ "x$LAPACKROOT" != "x" ]
@ -23,8 +24,8 @@ if [ "x$IMKLROOT" != "x" ]
then export IMKLROOT=${IMKLROOT} then export IMKLROOT=${IMKLROOT}
fi fi
if [ "x$DAMASKFORTRAN" != "x" ] if [ "x$F90" != "x" ]
then export F90=$DAMASKFORTRAN then export F90=$F90
fi fi
# disable output in case of scp # disable output in case of scp

32
configure vendored
View File

@ -13,37 +13,17 @@ Sets up the pre and post processing tools of DAMASK
compilers = ['ifort','gfortran'] compilers = ['ifort','gfortran']
parser.add_option('--F90', dest='compiler', type='string', \ parser.add_option('--with-fc', dest='compiler', type='string', \
help='name of F90 [%default]') help='name of F90 [%default]')
parser.add_option('--FFTWROOT', dest='fftwroot', type='string', \ parser.add_option('--with-blas-lapack-dir', dest='fftwroot', type='string', \
help='root location of FFTW [%default]') help='root location of FFTW [%default]')
parser.add_option('--LAPACKROOT', dest='lapackroot', type='string', \ parser.add_option('--with-blas-lapack-type', dest='lapackroot', type='string', \
help='root location of LAPACK [%default]')
parser.add_option('--with-spectral-options', dest='lapackroot', type='string', \
help='root location of LAPACK [%default]') help='root location of LAPACK [%default]')
parser.add_option('--ACMLROOT', dest='acmlroot', type='string', \
help='root location of ACML [%default]')
parser.add_option('--IMKLROOT', dest='imklroot', type='string', \
help='root location of IMKL [%default]')
parser.set_defaults(compiler = {True:os.getenv('F90'),False:''}\
[os.getenv('F90')!=None])
parser.set_defaults(fftwroot = {True:os.getenv('FFTWROOT'),False:''}\
[os.getenv('FFTWROOT')!=None])
parser.set_defaults(lapackroot = {True:os.getenv('LAPACKROOT'),False:''}\
[os.getenv('LAPACKROOT')!=None])
parser.set_defaults(acmlroot = {True:os.getenv('ACMLROOT'),False:''}\
[os.getenv('ACMLROOT')!=None])
parser.set_defaults(imklroot = {True:os.getenv('IMKLROOT'),False:''}\
[os.getenv('IMKLROOT')!=None])
(options,filenames) = parser.parse_args() (options,filenames) = parser.parse_args()
if options.compiler not in compilers:
parser.error('compiler switch "F90" has to be one out of: %s'%(', '.join(compilers)))
f2py_compiler = {
'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"',
'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"',
}[options.compiler]
# changing dirs and compiler in makefile # changing dirs and compiler in makefile
compiler ={True:'ifort',False:'gfortran'}[\ compiler ={True:'ifort',False:'gfortran'}[\

View File

@ -4,83 +4,58 @@
import os,sys,glob,string,subprocess import os,sys,glob,string,subprocess
from damask import Environment from damask import Environment
from optparse import OptionParser, Option
# -----------------------------
class extendableOption(Option):
# -----------------------------
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
# taken from online tutorial http://docs.python.org/library/optparse.html
ACTIONS = Option.ACTIONS + ("extend",)
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
def take_action(self, action, dest, opt, value, values, parser):
if action == "extend":
lvalue = value.split(",")
values.ensure_value(dest, []).extend(lvalue)
else:
Option.take_action(self, action, dest, opt, value, values, parser)
########################################################
# MAIN
########################################################
parser = OptionParser(option_class=extendableOption, usage='%prog options', description = """
Sets up the pre and post processing tools of DAMASK
""" + string.replace('$Id$','\n','\\n')
)
compilers = ['ifort','gfortran']
parser.add_option('--F90', dest='compiler', type='string', \
help='name of F90 [%default]')
parser.add_option('--FFTWROOT', dest='fftwroot', type='string', \
help='root location of FFTW [%default]')
parser.add_option('--LAPACKROOT', dest='lapackroot', type='string', \
help='root location of LAPACK [%default]')
parser.add_option('--ACMLROOT', dest='acmlroot', type='string', \
help='root location of ACML [%default]')
parser.add_option('--IMKLROOT', dest='imklroot', type='string', \
help='root location of IMKL [%default]')
parser.set_defaults(compiler = {True:os.getenv('F90'),False:''}\
[os.getenv('F90')!=None])
parser.set_defaults(fftwroot = {True:os.getenv('FFTWROOT'),False:''}\
[os.getenv('FFTWROOT')!=None])
parser.set_defaults(lapackroot = {True:os.getenv('LAPACKROOT'),False:''}\
[os.getenv('LAPACKROOT')!=None])
parser.set_defaults(acmlroot = {True:os.getenv('ACMLROOT'),False:''}\
[os.getenv('ACMLROOT')!=None])
parser.set_defaults(imklroot = {True:os.getenv('IMKLROOT'),False:''}\
[os.getenv('IMKLROOT')!=None])
(options,filenames) = parser.parse_args()
if options.compiler not in compilers:
parser.error('compiler switch "F90" has to be one out of: %s'%(', '.join(compilers)))
f2py_compiler = {
'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"',
'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"',
}[options.compiler]
damaskEnv = Environment() damaskEnv = Environment()
baseDir = damaskEnv.relPath('installation/') baseDir = damaskEnv.relPath('installation/')
codeDir = damaskEnv.relPath('code/') codeDir = damaskEnv.relPath('code/')
if options.imklroot != '' and options.compiler != 'gfortran': try:
lib_lapack = '-L%s/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5 -lpthread -lm'%(options.imklroot) imklroot = damaskEnv.options['IMKLROOT']
elif options.acmlroot != '': except:
lib_lapack = '-L%s/%s64/lib -lacml'%(options.acmlroot,options.compiler) imklroot = os.getenv('IMKLROOT')
elif options.lapackroot != '': if imklroot == None: imklroot == '' # env not set
lib_lapack = '-L%s -llapack'%(options.lapack) # see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html
try:
acmlroot = damaskEnv.options['ACMLROOT']
except:
acmlroot = os.getenv('ACMLROOT')
if acmlroot == None: acmlroot == '' # env not set
try:
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']
if compiler not in compilers:
parser.error('compiler switch "F90" has to be one out of: %s'%(', '.join(compilers)))
f2py_compiler = {
'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"',
'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"',
}[compiler]
if imklroot != '' and compiler != 'gfortran':
lib_lapack = '-L%s/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5 -lpthread -lm'%(imklroot)
elif acmlroot != '':
lib_lapack = '-L%s/%s64/lib -lacml'%(acmlroot,compiler)
elif lapackroot != '':
lib_lapack = '-L%s -llapack'%(lapack) # see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html
execute = { \ execute = { \
'coreModule' : [ 'coreModule' : [
@ -94,7 +69,7 @@ execute = { \
#'f2py -h damask.core.pyf' +\ #'f2py -h damask.core.pyf' +\
#' --overwrite-signature --no-lower prec.f90 DAMASK_spectral_interface.f90 math.f90 mesh.f90', #' --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')), 'rm `readlink -f %s`' %(os.path.join(damaskEnv.relPath('lib/damask'),'core.so')), # do this using system remove
'f2py damask.core.pyf' +\ 'f2py damask.core.pyf' +\
' --build-dir ./' +\ ' --build-dir ./' +\
' -c --no-lower --fcompiler=%s'%(f2py_compiler) +\ ' -c --no-lower --fcompiler=%s'%(f2py_compiler) +\
@ -108,9 +83,9 @@ execute = { \
' %s'%'FEsolving.f90'+\ ' %s'%'FEsolving.f90'+\
' %s'%'mesh.f90'+\ ' %s'%'mesh.f90'+\
' %s'%'core_quit.f90'+\ ' %s'%'core_quit.f90'+\
' -L%s/lib -lfftw3'%(options.fftwroot)+\ ' -L%s/lib -lfftw3'%(fftwroot)+\
' %s'%lib_lapack, ' %s'%lib_lapack,
'mv %s `readlink -f %s`' %(os.path.join(codeDir,'core.so'),os.path.join(damaskEnv.relPath('lib/damask'),'core.so')), '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
] ]
} }

View File

@ -49,6 +49,23 @@ class Environment():
self.pathInfo[items[0].lower()] = os.path.normpath(os.path.join(self.relPath('lib/'),items[1])) self.pathInfo[items[0].lower()] = os.path.normpath(os.path.join(self.relPath('lib/'),items[1]))
except: except:
pass pass
def get_options(self):
try: # check for user-defined pathinfo
file = open(self.relPath('installation/options'))
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 isAvailable(self,software,noNeeded=-1): def isAvailable(self,software,noNeeded=-1):
licensesNeeded = {'abaqus' :5, licensesNeeded = {'abaqus' :5,
@ -66,4 +83,4 @@ class Environment():
return licenses[1] + noNeeded - licenses[0] return licenses[1] + noNeeded - licenses[0]
except IndexError: except IndexError:
print('Could not retrieve license information for %s'%software) print('Could not retrieve license information for %s'%software)
return 127 return 127