introduced rpath to tell executable where libraries are located

This commit is contained in:
Martin Diehl 2014-01-27 14:10:49 +00:00
parent a1cfc85d74
commit 02441bef0f
6 changed files with 61 additions and 37 deletions

View File

@ -25,24 +25,25 @@ if [ ! -z "$PS1" ]; then
echo Using environment with ... echo Using environment with ...
echo "DAMASK installation in $DAMASK_ROOT" echo "DAMASK installation in $DAMASK_ROOT"
echo "DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" echo "DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS"
echo "F90=$F90" echo "Compiler: F90=$F90"
echo "FFTW_ROOT=$FFTW_ROOT"
if [ "x$LAPACK_ROOT" != "x" ]; then if [ "x$LAPACK_ROOT" != "x" ]; then
echo "LAPACK_ROOT=$LAPACK_ROOT" echo "LAPACK libaries located in $LAPACK_ROOT"
fi fi
if [ "x$ACML_ROOT" != "x" ]; then if [ "x$ACML_ROOT" != "x" ]; then
echo "ACML_ROOT=$ACML_ROOT" echo "ACML libaries located in $ACML_ROOT"
fi fi
if [ "x$IMKL_ROOT" != "x" ]; then if [ "x$IMKL_ROOT" != "x" ]; then
echo "IMKL_ROOT=$IMKL_ROOT" echo "IMKL libaries located in $IMKL_ROOT"
fi fi
echo "MARC_ROOT=$MARC_ROOT" echo "MSC.Marc root $MARC_ROOT"
echo "HDF5_ROOT=$HDF5_ROOT (future use)" echo "FFTW libaries located in $FFTW_ROOT"
echo "HDF5 libaries located in $HDF5_ROOT (future use)"
fi fi
ulimit -s unlimited ulimit -s unlimited
ulimit -c 0 ulimit -c 0
ulimit -v unlimited ulimit -v unlimited
ulimit -m unlimited ulimit -m unlimited
export PYTHONPATH=$PYTHONPATH:$DAMASK_ROOT/lib export PYTHONPATH=$PYTHONPATH:$DAMASK_ROOT/lib
unset DAMASK_ROOT unset DAMASK_ROOT LAPACK_ROOT ACML_ROOT IMKL_ROOT MARC_ROOT FFTW_ROOT HDF5_ROOT

View File

@ -2,6 +2,13 @@ SHELL = /bin/sh
######################################################################################## ########################################################################################
# Makefile for the installation of DAMASK # Makefile for the installation of DAMASK
######################################################################################## ########################################################################################
.PHONY: all
all:
spectral
marc
processing
install
.PHONY: spectral .PHONY: spectral
spectral: spectral:
@$(MAKE) clean -C code >/dev/null @$(MAKE) clean -C code >/dev/null

View File

@ -41,12 +41,12 @@ else
include /etc/damask.conf include /etc/damask.conf
endif endif
COMPILERNAME ?= $(F90) COMPILERNAME ?= $(F90)
INCLUDE_DIRS :=-I../lib INCLUDE_DIRS :=-I../lib
LIBRARIES :=-lfftw3 LIBRARIES :=-lfftw3
LIB_DIRS :=-L$$FFTW_ROOT/lib LIB_DIRS :=-L$(FFTW_ROOT)/lib
RUN_PATH :=-Wl,-rpath,$(FFTW_ROOT)/lib
ifeq "$(FASTBUILD)" "YES" ifeq "$(FASTBUILD)" "YES"
OPENMP := OFF OPENMP := OFF
@ -94,29 +94,30 @@ IMKL_ARCH =_sequential
endif endif
ifneq "x$(IMKL_ROOT)" "x" ifneq "x$(IMKL_ROOT)" "x"
LIB_DIRS :=-L$$IMKL_ROOT/lib/intel64 LIB_DIRS :=-L$(IMKL_ROOT)/lib/intel64
RUN_PATH +=$(RUNPATH) -Wl,-rpath,$(IMKL_ROOT)/lib/intel64
INCLUDE_DIRS +=-I$(IMKL_ROOT)/include INCLUDE_DIRS +=-I$(IMKL_ROOT)/include
LIBRARIES +=-lmkl_intel_lp64 -lmkl_core -lmkl$(ACML_ARCH) -lm -lpthread -liomp5 LIBRARIES +=-lmkl_intel_lp64 -lmkl_core -lmkl$(ACML_ARCH) -lm -lpthread -liomp5
else else
ifneq "x$(ACML_ROOT)" "x" ifneq "x$(ACML_ROOT)" "x"
LIB_DIRS +=-L$$ACML_ROOT/$(F90)64$(ACML_ARCH)/lib LIB_DIRS +=-L$(ACML_ROOT)/$(F90)64$(ACML_ARCH)/lib
RUN_PATH +=$(RUNPATH) -Wl,-rpath,$(ACML_ROOT)/$(F90)64$(ACML_ARCH)/lib
LIBRARIES +=-lacml$(ACML_ARCH) LIBRARIES +=-lacml$(ACML_ARCH)
else else
ifneq "x$(LAPACK_ROOT)" "x" ifneq "x$(LAPACK_ROOT)" "x"
LIB_DIRS +=-L$$LAPACK_ROOT/lib64 -L$$LAPACK_ROOT/lib LIB_DIRS +=-L$(LAPACK_ROOT)/lib64 -L$(LAPACK_ROOT)/lib
RUN_PATH +=$(RUN_PATH) -Wl,-rpath,$(LAPACK_ROOT)/lib64 -Wl,-rpath,$(LAPACK_ROOT)/lib
LIBRARIES +=-llapack LIBRARIES +=-llapack
endif endif
endif endif
endif endif
#hdf5 #hdf5
ifeq "$(HDF5)" "ON" ifeq "$(HDF5)" "ON"
LIBRARIES +=-lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 LIBRARIES +=-lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5
LIB_DIRS +=-L$$HDF5ROOT/lib LIB_DIRS +=-L$(HDF5_ROOT)/lib
INCLUDE_DIRS +=-I$(HDF5ROOT)/include -DHDF RUN_PATH +=$(RUNPATH) -Wl,-rpath,$(HDF5_ROOT)/lib
INCLUDE_DIRS +=-I$(HDF5_ROOT)/include -DHDF
endif endif
ifdef PETSC_DIR ifdef PETSC_DIR
@ -360,7 +361,7 @@ endif
DAMASK_spectral.exe: DAMASK_spectral_driver.o DAMASK_spectral.exe: DAMASK_spectral_driver.o
$(PREFIX) $(COMPILERNAME) $(OPENMP_FLAG_$(F90)) $(OPTIMIZATION_$(MAXOPTI)_$(F90)) $(STANDARD_CHECK_$(F90)) \ $(PREFIX) $(COMPILERNAME) $(OPENMP_FLAG_$(F90)) $(OPTIMIZATION_$(MAXOPTI)_$(F90)) $(STANDARD_CHECK_$(F90)) \
-o DAMASK_spectral.exe DAMASK_spectral_driver.o \ -o DAMASK_spectral.exe DAMASK_spectral_driver.o \
$(COMPILED_FILES) $(LIB_DIRS) $(LIBRARIES) $(SUFFIX) $(COMPILED_FILES) $(LIB_DIRS) $(LIBRARIES) $(RUN_PATH) $(SUFFIX)
DAMASK_spectral_driver.o: DAMASK_spectral_driver.f90 DAMASK_spectral_solverBasic.o $(PETSC_FILES) DAMASK_spectral_driver.o: DAMASK_spectral_driver.f90 DAMASK_spectral_solverBasic.o $(PETSC_FILES)
$(PREFIX) $(COMPILERNAME) $(COMPILE_MAXOPTI) -c DAMASK_spectral_driver.f90 $(SUFFIX) $(PREFIX) $(COMPILERNAME) $(COMPILE_MAXOPTI) -c DAMASK_spectral_driver.f90 $(SUFFIX)

9
configure vendored
View File

@ -142,7 +142,7 @@ if options.compiler not in ['ifort','gfortran']:
if not subprocess.call(['which', options.compiler],stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0: if not subprocess.call(['which', options.compiler],stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0:
print('Compiler Warning: executable %s not found!'%options.compiler) print('Compiler Warning: executable %s not found!'%options.compiler)
for lib in ['libfftw3.a','libfftw3.a']: for lib in ['libfftw3.so','libfftw3.a']:
if not os.path.isfile(os.path.join(options.fftwRoot,'lib/%s'%lib)): if not os.path.isfile(os.path.join(options.fftwRoot,'lib/%s'%lib)):
print('FFTW Warning: %s not found in %s!'%(lib,os.path.join(options.fftwRoot,'lib'))) print('FFTW Warning: %s not found in %s!'%(lib,os.path.join(options.fftwRoot,'lib')))
@ -154,16 +154,16 @@ if options.blasType == 'LAPACK':
blasLocation = os.path.join(options.blasRoot,'lib64') blasLocation = os.path.join(options.blasRoot,'lib64')
else: else:
blasLocation=os.path.join(options.blasRoot,'lib') blasLocation=os.path.join(options.blasRoot,'lib')
for lib in ['liblapack.a','liblapack.a']: for lib in ['liblapack.so','liblapack.a']:
if not os.path.isfile(os.path.join(blasLocation,lib)): if not os.path.isfile(os.path.join(blasLocation,lib)):
print('LAPACK Warning: %s not found in %s!'%(lib,blasLocation)) print('LAPACK Warning: %s not found in %s!'%(lib,blasLocation))
elif options.blasType == 'ACML': elif options.blasType == 'ACML':
blasLocationSerial=os.path.join(options.blasRoot,'%s64/lib'%options.compiler) blasLocationSerial=os.path.join(options.blasRoot,'%s64/lib'%options.compiler)
for lib in ['libacml.a','libacml.a']: for lib in ['libacml.so','libacml.a']:
if not os.path.isfile(os.path.join(blasLocationSerial,lib)): if not os.path.isfile(os.path.join(blasLocationSerial,lib)):
print('ACML Warning: %s not found in %s!'%(lib,blasLocationSerial)) print('ACML Warning: %s not found in %s!'%(lib,blasLocationSerial))
blasLocationParallel=os.path.join(options.blasRoot,'%s64_mp/lib'%options.compiler) blasLocationParallel=os.path.join(options.blasRoot,'%s64_mp/lib'%options.compiler)
for lib in ['libacml_mp.a','libacml_mp.a']: for lib in ['libacml_mp.so','libacml_mp.a']:
if not os.path.isfile(os.path.join(blasLocationParallel,lib)): if not os.path.isfile(os.path.join(blasLocationParallel,lib)):
print('ACML Warning: %s not found in %s!'%(lib,blasLocationParallel)) print('ACML Warning: %s not found in %s!'%(lib,blasLocationParallel))
elif options.blasType == 'IMKL': elif options.blasType == 'IMKL':
@ -173,6 +173,7 @@ elif options.blasType == 'IMKL':
blasLocation=os.path.join(options.blasRoot,'lib/intel64') blasLocation=os.path.join(options.blasRoot,'lib/intel64')
for lib in ['libmkl_core.so','libmkl_core.a',\ for lib in ['libmkl_core.so','libmkl_core.a',\
'libmkl_sequential.so','libmkl_sequential.a',\ 'libmkl_sequential.so','libmkl_sequential.a',\
'libmkl_intel_thread.so','libmkl_intel_thread.a',\
'libmkl_intel_lp64.so','libmkl_intel_lp64.a']: 'libmkl_intel_lp64.so','libmkl_intel_lp64.a']:
if not os.path.isfile(os.path.join(blasLocation,lib)): if not os.path.isfile(os.path.join(blasLocation,lib)):
print('IMKL Warning: %s not found in %s!'%(lib,blasLocation)) print('IMKL Warning: %s not found in %s!'%(lib,blasLocation))

View File

@ -23,20 +23,29 @@ compilers = ['ifort','gfortran']
if options['F90'] not in compilers: if options['F90'] not in compilers:
sys.exit('compiler "F90" (in installation/options or as Shell variable) 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)))
compileCommand = { compiler = {
'gfortran': 'gnu95 --f90flags="-fPIC -fno-range-check -xf95-cpp-input -std=f2008 -fall-intrinsics'+\ 'gfortran': '--fcompiler=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%s/lib"'%damaskEnv.rootDir(), ' -fdefault-real-8 -fdefault-double-8"',
'ifort': 'intelem --f90flags="-fPIC -fpp -stand f08 -diag-disable 5268 -assume byterecl'+\ 'ifort': '--fcompiler=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(), ' -real-size 64 -integer-size 32"',
}[options['F90']] }[options['F90']]
# option not depending on compiler
compileOptions =' -DSpectral -DFLOAT=8 -DINT=4 -I%s/lib'%damaskEnv.rootDir()
# this saves the path of libraries during runtime
LDFLAGS ='-Wl,-rpath,%s/lib'%(options['FFTW_ROOT'])
# see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html # see http://cens.ioc.ee/pipermail/f2py-users/2003-December/000621.html
if options['IMKL_ROOT'] != '' and options['F90'] != 'gfortran': if options['IMKL_ROOT'] != '' and options['F90'] != 'gfortran':
lib_lapack = '-L$IMKL_ROOT/lib/intel64 -I%s/include -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm -liomp5'%options['IMKL_ROOT'] lib_lapack = '-L%s/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm -liomp5'%options['IMKL_ROOT']
LDFLAGS +=' -Wl,-rpath,%s/lib/intel64'%(options['IMKL_ROOT'])
elif options['ACML_ROOT'] != '': elif options['ACML_ROOT'] != '':
lib_lapack = '-L$ACML/%s64/lib -lacml'%options['F90'] lib_lapack = '-L%s/%s64/lib -lacml'%(options['ACML_ROOT'],options['F90'])
LDFLAGS +=' -Wl,-rpath,%s/%s64/lib'%(options['ACML_ROOT'],options['F90'])
elif options['LAPACK_ROOT'] != '': elif options['LAPACK_ROOT'] != '':
lib_lapack = '-L$LAPACK_ROOT/lib -L$LAPACK_ROOT/lib64 -llapack' lib_lapack = '-L%s/lib -L%s/lib64 -llapack'%(options['LAPACK_ROOT'],options['LAPACK_ROOT'])
LDFLAGS +=' -Wl,-rpath,%s/lib -Wl,-rpath,%s/lib64'%(options['LAPACK_ROOT'],options['LAPACK_ROOT'])
os.chdir(codeDir) # needed for compilation with gfortran and f2py os.chdir(codeDir) # needed for compilation with gfortran and f2py
try: try:
@ -55,7 +64,8 @@ except OSError, e:
#' --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,...'
########################################################################### ###########################################################################
cmd = 'f2py damask.core.pyf' +\ cmd = 'f2py damask.core.pyf' +\
' -c --no-lower --fcompiler=%s'%(compileCommand) +\ ' -c --no-lower %s'%(compiler) +\
compileOptions+\
' prec.f90'+\ ' prec.f90'+\
' DAMASK_spectral_interface.f90'+\ ' DAMASK_spectral_interface.f90'+\
' IO.f90'+\ ' IO.f90'+\
@ -66,12 +76,16 @@ cmd = 'f2py damask.core.pyf' +\
' FEsolving.f90'+\ ' FEsolving.f90'+\
' mesh.f90'+\ ' mesh.f90'+\
' core_quit.f90'+\ ' core_quit.f90'+\
' -L$FFTW_ROOT/lib -lfftw3'+\ ' -L%s/lib -lfftw3'%(options['FFTW_ROOT'])+\
' %s'%lib_lapack ' %s'%lib_lapack
# f2py does not (yet) support setting of special flags for the linker, hence they must be set via
# environment variable
my_env = os.environ
my_env["LDFLAGS"] = LDFLAGS
print('Executing: '+cmd) print('Executing: '+cmd)
try: try:
subprocess.call(shlex.split(cmd)) subprocess.call(shlex.split(cmd),env=my_env)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print('build failed') print('build failed')
except OSError: except OSError:

View File

@ -60,13 +60,13 @@ BLASDIR=${BLASDIR%/} # remove trailing slash
case $BLASTYPE in case $BLASTYPE in
IMKL | imkl) IMKL | imkl)
BLAS=" -mkl" BLAS=" -mkl=sequential -lpthread -lm -rpath=$BLASDIR/lib/intel64" #rpoath
;; ;;
ACML | acml) ACML | acml)
BLAS=" -L$BLASDIR/ifort64_mp/lib -lacml_mp" BLAS=" -L$BLASDIR/ifort64/lib -lacml -rpath=$BLASDIR/ifort64/lib"
;; ;;
LAPACK | lapack) LAPACK | lapack)
BLAS=" -L$BLASDIR/lib64 -L$BLASDIR/lib -llapack" BLAS=" -L$BLASDIR/lib64 -L$BLASDIR/lib -llapack -rpath=$BLASDIR/lib64 -rpath$BLASDIR/lib"
;; ;;
*) *)
echo "error, BLAS type must be IMKL, ACML, or LAPACK" echo "error, BLAS type must be IMKL, ACML, or LAPACK"