From f146359c04563ba45cc16679632c877b555876f8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 28 Feb 2014 07:47:11 +0000 Subject: [PATCH] added --prefix option to configure script to specify symlink location --- DAMASK_env.sh | 19 ++++++++++++-- configure | 41 +++++++++++++++++------------- installation/symlink_Code.py | 18 ++++++++----- installation/symlink_Processing.py | 19 ++++++++------ 4 files changed, 63 insertions(+), 34 deletions(-) diff --git a/DAMASK_env.sh b/DAMASK_env.sh index befb13a67..371e69ee3 100644 --- a/DAMASK_env.sh +++ b/DAMASK_env.sh @@ -11,6 +11,20 @@ fi [[ -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 if [ ! -z "$PS1" ]; then @@ -21,6 +35,8 @@ if [ ! -z "$PS1" ]; then echo echo Using environment with ... 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 "Compiler F90=$F90" ([[ "x$IMKL_ROOT" != "x" ]] && echo "IMKL $IMKL_ROOT") || \ @@ -30,8 +46,7 @@ if [ ! -z "$PS1" ]; then echo "FFTW $FFTW_ROOT" echo "HDF5 $HDF5_ROOT (for future use)" echo -fi - + fi # http://superuser.com/questions/220059/what-parameters-has-ulimit ulimit -s unlimited 2>/dev/null # maximum stack size (kB) ulimit -h unlimited 2>/dev/null # maximum heap size (kB) diff --git a/configure b/configure index ad45839e2..03a585315 100755 --- a/configure +++ b/configure @@ -42,7 +42,8 @@ if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\ #--- default option values -------------------------------------------------------------------------- BLAS_order = ['IMKL','ACML','LAPACK'] -defaults={'F90':compiler, +defaults={'DAMASK_BIN':'depending on access rights', + 'F90':compiler, 'FFTW_ROOT':'/usr/local', 'MSC_ROOT' :'/msc', 'HDF5_ROOT':'/usr/local', @@ -54,6 +55,8 @@ defaults={'F90':compiler, [os.getenv('MKLROOT') != None]}, 'spectralOptions':{}} + + #--- if local config file exists, read, otherwise assume global config file ------------------------ if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')): configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf') @@ -67,23 +70,25 @@ try: for line in f: [key,value] = (re.split('[= ]',line)+[None,None])[:2] value = value.rstrip() - + if (not line.strip() or key.startswith('#')): pass if key == 'DAMASK_NUM_THREADS': 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']: if key == theKey: defaults[key] = value for theKey in reversed(BLAS_order): if key == theKey+'_ROOT' and (value != None or value != ''): - defaults['blasType'] = key - defaults['blasRoot'][key] = value + defaults['blasType'] = theKey + defaults['blasRoot'][theKey] = value except IOError: 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', help='F90 compiler [%default]') 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='', help='options for compilation of spectral solver') +parser.set_defaults(prefix = defaults['DAMASK_BIN']) parser.set_defaults(compiler = defaults['F90']) parser.set_defaults(fftwRoot = defaults['FFTW_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']) #--- set default for blasRoot depending on current option (or default) for blasType -------------------- - blasType = defaults['blasType'].upper() for i, arg in enumerate(sys.argv): if arg.startswith('--with-blas-type'): @@ -118,7 +123,7 @@ for i, arg in enumerate(sys.argv): else: blasType = sys.argv[i][17:].upper() if blasType not in BLAS_order: - blasType = 'LAPACK' + blasType='LAPACK' parser.set_defaults(blasRoot = [defaults['blasRoot'][blasType]][0]) parser.set_defaults(spectraloptions = []) @@ -180,7 +185,6 @@ else: print('Error: Unknown BLAS/LAPACK library: %s'%options.blasType) sys.exit(1) - #--- read config file if present to keep comments and order --------------------------------------- output = [] try: @@ -190,6 +194,9 @@ try: if (not line.strip() or items[0].startswith('#')): pass + if items[0] == 'DAMASK_BIN': + line = '%s=%s\n'%(items[0],options.prefix) + options.prefix ='depending on access rights' if items[0] == 'F90': line = '%s=%s\n'%(items[0],options.compiler) options.compiler ='' @@ -224,6 +231,8 @@ except IOError: #--- write remaining options -------------------------------------------------------------------------- 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 !='': output.append('F90=%s\n'%value) if opt == 'fftwRoot' and value !='': @@ -240,14 +249,12 @@ for opt, value in options.__dict__.items(): for spectralOption in options.spectraloptions: output.append(spectralOption+'\n') -#--- decide where do save the data ---------------------------------------------------------------------- -root=os.access('/etc/', os.W_OK) -if root: - configFileNew = '/etc/damask.conf' -else: - configFileNew = os.path.join(os.getenv('HOME'),'.damask/damask.conf') - if not os.path.isdir(os.path.join(os.getenv('HOME'),'.damask')): - os.mkdir(os.path.join(os.getenv('HOME'),'.damask')) +#--- decide where do save the data ------------------------------------------------------------------- +if os.access('/etc/', os.W_OK): # super user (no home) + configDir = '/etc' +else: # normal user + configDir = os.path.join(os.getenv('HOME'),'.damask') +configFileNew = os.path.join(configDir,'damask.conf') print('\n-----\n writing values to %s\n-----'%configFileNew) with open(configFileNew,'w') as f: diff --git a/installation/symlink_Code.py b/installation/symlink_Code.py index 2685a3ce8..64301056b 100755 --- a/installation/symlink_Code.py +++ b/installation/symlink_Code.py @@ -12,13 +12,17 @@ MarcReleases =[2011,2012,2013,2013.1] baseDir = damask.Environment('../../').relPath('code/') -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) +try: + binDir = damask.Environment().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) for dir in bin_link: for file in bin_link[dir]: diff --git a/installation/symlink_Processing.py b/installation/symlink_Processing.py index f610d501c..9543c4ca7 100755 --- a/installation/symlink_Processing.py +++ b/installation/symlink_Processing.py @@ -7,6 +7,17 @@ from damask import Environment damaskEnv = Environment() baseDir = damaskEnv.relPath('processing/') 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 bin_link = { \ @@ -81,14 +92,6 @@ bin_link = { \ 'vtk_addVoxelcloudData.py', ], } - -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 file in bin_link[dir]: