added --prefix option to configure script to specify symlink location

This commit is contained in:
Martin Diehl 2014-02-28 07:47:11 +00:00
parent fe13bb16fe
commit f146359c04
4 changed files with 63 additions and 34 deletions

View File

@ -11,6 +11,20 @@ fi
[[ -f $HOME/.damask/damask.conf ]] && source $HOME/.damask/damask.conf || source /etc/damask.conf [[ -f $HOME/.damask/damask.conf ]] && source $HOME/.damask/damask.conf || source /etc/damask.conf
# if DAMASK_BIN is present and not in $PATH, add it
if [[ "x$DAMASK_BIN" != "x" && ! `echo ":$PATH:" | grep $DAMASK_BIN:` ]]; then
export PATH=$DAMASK_BIN:$PATH
fi
SOLVER=`which DAMASK_spectral`
if [ "x$SOLVER" == "x" ]; then
export SOLVER='Not found!'
fi
PROCESSING=`which postResults`
if [ "x$PROCESSING" == "x" ]; then
export PROCESSING='Not found!'
fi
echo "DAMASK_spectral `which DAMASK_spectral`"
# disable output in case of scp # disable output in case of scp
if [ ! -z "$PS1" ]; then if [ ! -z "$PS1" ]; then
@ -21,6 +35,8 @@ if [ ! -z "$PS1" ]; then
echo echo
echo Using environment with ... echo Using environment with ...
echo "DAMASK $DAMASK_ROOT" echo "DAMASK $DAMASK_ROOT"
([[ "x$SOLVER" != "x" ]] && echo "Spectral Solver $SOLVER")
([[ "x$PROCESSING" != "x" ]] && echo "Post Processing $PROCESSING")
echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS"
echo "Compiler F90=$F90" echo "Compiler F90=$F90"
([[ "x$IMKL_ROOT" != "x" ]] && echo "IMKL $IMKL_ROOT") || \ ([[ "x$IMKL_ROOT" != "x" ]] && echo "IMKL $IMKL_ROOT") || \
@ -30,8 +46,7 @@ if [ ! -z "$PS1" ]; then
echo "FFTW $FFTW_ROOT" echo "FFTW $FFTW_ROOT"
echo "HDF5 $HDF5_ROOT (for future use)" echo "HDF5 $HDF5_ROOT (for future use)"
echo echo
fi fi
# http://superuser.com/questions/220059/what-parameters-has-ulimit # http://superuser.com/questions/220059/what-parameters-has-ulimit
ulimit -s unlimited 2>/dev/null # maximum stack size (kB) ulimit -s unlimited 2>/dev/null # maximum stack size (kB)
ulimit -h unlimited 2>/dev/null # maximum heap size (kB) ulimit -h unlimited 2>/dev/null # maximum heap size (kB)

39
configure vendored
View File

@ -42,7 +42,8 @@ if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\
#--- default option values -------------------------------------------------------------------------- #--- default option values --------------------------------------------------------------------------
BLAS_order = ['IMKL','ACML','LAPACK'] BLAS_order = ['IMKL','ACML','LAPACK']
defaults={'F90':compiler, defaults={'DAMASK_BIN':'depending on access rights',
'F90':compiler,
'FFTW_ROOT':'/usr/local', 'FFTW_ROOT':'/usr/local',
'MSC_ROOT' :'/msc', 'MSC_ROOT' :'/msc',
'HDF5_ROOT':'/usr/local', 'HDF5_ROOT':'/usr/local',
@ -54,6 +55,8 @@ defaults={'F90':compiler,
[os.getenv('MKLROOT') != None]}, [os.getenv('MKLROOT') != None]},
'spectralOptions':{}} 'spectralOptions':{}}
#--- if local config file exists, read, otherwise assume global config file ------------------------ #--- if local config file exists, read, otherwise assume global config file ------------------------
if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')): if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')):
configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf') configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf')
@ -72,18 +75,20 @@ try:
pass pass
if key == 'DAMASK_NUM_THREADS': if key == 'DAMASK_NUM_THREADS':
defaults['DAMASK_NUM_THREADS'] = int(value) defaults['DAMASK_NUM_THREADS'] = int(value)
if key == 'DAMASK_BIN':
defaults['DAMASK_BIN'] = value
for theKey in ['F90','FFTW_ROOT','HDF5_ROOT','MSC_ROOT','spectralOptions']: for theKey in ['F90','FFTW_ROOT','HDF5_ROOT','MSC_ROOT','spectralOptions']:
if key == theKey: if key == theKey:
defaults[key] = value defaults[key] = value
for theKey in reversed(BLAS_order): for theKey in reversed(BLAS_order):
if key == theKey+'_ROOT' and (value != None or value != ''): if key == theKey+'_ROOT' and (value != None or value != ''):
defaults['blasType'] = key defaults['blasType'] = theKey
defaults['blasRoot'][key] = value defaults['blasRoot'][theKey] = value
except IOError: except IOError:
pass pass
parser.add_option('--prefix', dest='prefix', type='string', metavar='string',
help='location of (links to) DAMASK executables [%default]')
parser.add_option('--with-fc', dest='compiler', type='string', metavar='string', parser.add_option('--with-fc', dest='compiler', type='string', metavar='string',
help='F90 compiler [%default]') help='F90 compiler [%default]')
parser.add_option('--with-fftw-dir', dest='fftwRoot', type='string', metavar='string', parser.add_option('--with-fftw-dir', dest='fftwRoot', type='string', metavar='string',
@ -101,6 +106,7 @@ parser.add_option('--with-blas-dir', dest='blasRoot', type='string', met
parser.add_option('--with-spectral-options', dest='spectraloptions', type='string', action='extend', metavar='<string LIST>', parser.add_option('--with-spectral-options', dest='spectraloptions', type='string', action='extend', metavar='<string LIST>',
help='options for compilation of spectral solver') help='options for compilation of spectral solver')
parser.set_defaults(prefix = defaults['DAMASK_BIN'])
parser.set_defaults(compiler = defaults['F90']) parser.set_defaults(compiler = defaults['F90'])
parser.set_defaults(fftwRoot = defaults['FFTW_ROOT']) parser.set_defaults(fftwRoot = defaults['FFTW_ROOT'])
parser.set_defaults(mscRoot = defaults['MSC_ROOT']) parser.set_defaults(mscRoot = defaults['MSC_ROOT'])
@ -109,7 +115,6 @@ parser.set_defaults(threads = defaults['DAMASK_NUM_THREADS'])
parser.set_defaults(blasType = defaults['blasType']) parser.set_defaults(blasType = defaults['blasType'])
#--- set default for blasRoot depending on current option (or default) for blasType -------------------- #--- set default for blasRoot depending on current option (or default) for blasType --------------------
blasType = defaults['blasType'].upper() blasType = defaults['blasType'].upper()
for i, arg in enumerate(sys.argv): for i, arg in enumerate(sys.argv):
if arg.startswith('--with-blas-type'): if arg.startswith('--with-blas-type'):
@ -118,7 +123,7 @@ for i, arg in enumerate(sys.argv):
else: else:
blasType = sys.argv[i][17:].upper() blasType = sys.argv[i][17:].upper()
if blasType not in BLAS_order: if blasType not in BLAS_order:
blasType = 'LAPACK' blasType='LAPACK'
parser.set_defaults(blasRoot = [defaults['blasRoot'][blasType]][0]) parser.set_defaults(blasRoot = [defaults['blasRoot'][blasType]][0])
parser.set_defaults(spectraloptions = []) parser.set_defaults(spectraloptions = [])
@ -180,7 +185,6 @@ else:
print('Error: Unknown BLAS/LAPACK library: %s'%options.blasType) print('Error: Unknown BLAS/LAPACK library: %s'%options.blasType)
sys.exit(1) sys.exit(1)
#--- read config file if present to keep comments and order --------------------------------------- #--- read config file if present to keep comments and order ---------------------------------------
output = [] output = []
try: try:
@ -190,6 +194,9 @@ try:
if (not line.strip() or items[0].startswith('#')): if (not line.strip() or items[0].startswith('#')):
pass pass
if items[0] == 'DAMASK_BIN':
line = '%s=%s\n'%(items[0],options.prefix)
options.prefix ='depending on access rights'
if items[0] == 'F90': if items[0] == 'F90':
line = '%s=%s\n'%(items[0],options.compiler) line = '%s=%s\n'%(items[0],options.compiler)
options.compiler ='' options.compiler =''
@ -224,6 +231,8 @@ except IOError:
#--- write remaining options -------------------------------------------------------------------------- #--- write remaining options --------------------------------------------------------------------------
for opt, value in options.__dict__.items(): for opt, value in options.__dict__.items():
if opt == 'prefix' and value !='depending on access rights':
output.append('DAMASK_BIN=%s\n'%value)
if opt == 'compiler' and value !='': if opt == 'compiler' and value !='':
output.append('F90=%s\n'%value) output.append('F90=%s\n'%value)
if opt == 'fftwRoot' and value !='': if opt == 'fftwRoot' and value !='':
@ -240,14 +249,12 @@ for opt, value in options.__dict__.items():
for spectralOption in options.spectraloptions: for spectralOption in options.spectraloptions:
output.append(spectralOption+'\n') output.append(spectralOption+'\n')
#--- decide where do save the data ---------------------------------------------------------------------- #--- decide where do save the data -------------------------------------------------------------------
root=os.access('/etc/', os.W_OK) if os.access('/etc/', os.W_OK): # super user (no home)
if root: configDir = '/etc'
configFileNew = '/etc/damask.conf' else: # normal user
else: configDir = os.path.join(os.getenv('HOME'),'.damask')
configFileNew = os.path.join(os.getenv('HOME'),'.damask/damask.conf') configFileNew = os.path.join(configDir,'damask.conf')
if not os.path.isdir(os.path.join(os.getenv('HOME'),'.damask')):
os.mkdir(os.path.join(os.getenv('HOME'),'.damask'))
print('\n-----\n writing values to %s\n-----'%configFileNew) print('\n-----\n writing values to %s\n-----'%configFileNew)
with open(configFileNew,'w') as f: with open(configFileNew,'w') as f:

View File

@ -12,12 +12,16 @@ MarcReleases =[2011,2012,2013,2013.1]
baseDir = damask.Environment('../../').relPath('code/') baseDir = damask.Environment('../../').relPath('code/')
root=os.access('/usr/local/bin', os.W_OK) try:
if root: binDir = damask.Environment().options['DAMASK_BIN']
except:
root=os.access('/usr/local/bin', os.W_OK)
if root:
binDir = '/usr/local/bin' binDir = '/usr/local/bin'
else: else:
binDir = os.path.join(os.getenv('HOME'),'bin') binDir = os.path.join(os.getenv('HOME'),'bin')
if not os.path.isdir(binDir):
if not os.path.isdir(binDir):
os.mkdir(binDir) os.mkdir(binDir)
for dir in bin_link: for dir in bin_link:

View File

@ -7,6 +7,17 @@ from damask import Environment
damaskEnv = Environment() damaskEnv = Environment()
baseDir = damaskEnv.relPath('processing/') baseDir = damaskEnv.relPath('processing/')
codeDir = damaskEnv.relPath('code/') codeDir = damaskEnv.relPath('code/')
try:
binDir = damaskEnv.options['DAMASK_BIN']
except:
root=os.access('/usr/local/bin', os.W_OK)
if root:
binDir = '/usr/local/bin'
else:
binDir = os.path.join(os.getenv('HOME'),'bin')
if not os.path.isdir(binDir):
os.mkdir(binDir)
#define ToDo list #define ToDo list
bin_link = { \ bin_link = { \
@ -82,14 +93,6 @@ bin_link = { \
], ],
} }
root=os.access('/usr/local/bin', os.W_OK)
if root:
binDir = '/usr/local/bin'
else:
binDir = os.path.join(os.getenv('HOME'),'bin')
if not os.path.isdir(binDir):
os.mkdir(binDir)
for dir in bin_link: for dir in bin_link:
for file in bin_link[dir]: for file in bin_link[dir]:
src = os.path.abspath(os.path.join(baseDir,dir,file)) src = os.path.abspath(os.path.join(baseDir,dir,file))