2014-01-11 18:16:30 +05:30
|
|
|
#!/usr/bin/env python
|
2014-01-14 02:47:28 +05:30
|
|
|
import os,re,sys,string,subprocess
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-11 19:58:07 +05:30
|
|
|
########################################################
|
|
|
|
# MAIN
|
|
|
|
########################################################
|
2014-01-11 18:16:30 +05:30
|
|
|
|
2014-01-11 19:58:07 +05:30
|
|
|
parser = OptionParser(option_class=extendableOption, usage='%prog options', description = """
|
|
|
|
Sets up the pre and post processing tools of DAMASK
|
2014-01-11 18:16:30 +05:30
|
|
|
|
2014-01-11 19:58:07 +05:30
|
|
|
""" + string.replace('$Id$','\n','\\n')
|
|
|
|
)
|
2014-01-11 18:16:30 +05:30
|
|
|
|
2014-01-11 19:58:07 +05:30
|
|
|
compilers = ['ifort','gfortran']
|
2014-01-14 19:42:35 +05:30
|
|
|
blastypes = ['LAPACK','ACML','IMKL']
|
2014-01-11 19:58:07 +05:30
|
|
|
|
2014-01-14 19:42:35 +05:30
|
|
|
parser.add_option('--with-fc', dest='compiler', type='string',
|
|
|
|
help='F90 compiler [%default]')
|
|
|
|
parser.add_option('--with-marc-dir', dest='marcdir', type='string',
|
|
|
|
help='root directory of MSC.Marc [%default]')
|
|
|
|
parser.add_option('--with-fftw-dir', dest='fftwdir', type='string',
|
|
|
|
help='root directory of FFTW [%default]')
|
|
|
|
parser.add_option('--with-blas-lapack-dir', dest='blasdir', type='string',
|
|
|
|
help='root directory of LAPACK [%default]')
|
|
|
|
parser.add_option('--with-blas-type', dest='blastype', type='string',
|
|
|
|
help='type of BLAS/LAPACK library [%default]')
|
|
|
|
parser.add_option('--with-spectral-options', dest='spectraloptions', type='string',
|
|
|
|
help='options for spectral solver [%default]')
|
2014-01-11 19:58:07 +05:30
|
|
|
|
2014-01-14 02:47:28 +05:30
|
|
|
compiler = os.getenv('F90')
|
|
|
|
if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\
|
|
|
|
subprocess.call(['which', 'ifort'],\
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0]
|
2014-01-14 19:42:35 +05:30
|
|
|
parser.set_defaults(compiler = compiler)
|
|
|
|
parser.set_defaults(blastype = 'LAPACK')
|
|
|
|
parser.set_defaults(fftwdir = "/usr/local")
|
|
|
|
parser.set_defaults(blasdir = "/usr")
|
|
|
|
parser.set_defaults(marcdir = "/msc")
|
|
|
|
|
2014-01-11 19:58:07 +05:30
|
|
|
(options,filenames) = parser.parse_args()
|
2014-01-14 19:42:35 +05:30
|
|
|
|
|
|
|
options.blastype = options.blastype.upper()
|
|
|
|
options.compiler = options.compiler.lower()
|
|
|
|
|
2014-01-14 02:47:28 +05:30
|
|
|
if options.blastype not in blastypes: print('Unknown BLAS type selected')
|
|
|
|
if options.compiler not in compilers: print('Unknown compiler type selected')
|
2014-01-11 19:58:07 +05:30
|
|
|
|
2014-01-14 19:42:35 +05:30
|
|
|
output = []
|
|
|
|
with open('installation/options','r') as f:
|
|
|
|
for line in f:
|
|
|
|
items = re.split('[= ]',line)
|
|
|
|
|
|
|
|
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] == 'MSCROOT': line = '%s=%s\n'%(items[0],options.marcdir)
|
|
|
|
for type in blastypes:
|
|
|
|
if options.blastype == type and items[0] == '%sROOT'%type:
|
|
|
|
line = '%s=%s\n'%(items[0],options.blasdir)
|
|
|
|
|
|
|
|
output.append(line)
|
|
|
|
|
|
|
|
with open('installation/options','w') as f:
|
|
|
|
for line in output:
|
|
|
|
f.write(line)
|