2013-01-29 20:58:21 +05:30
|
|
|
#!/usr/bin/env python
|
2013-02-01 17:51:56 +05:30
|
|
|
|
2013-02-14 00:15:49 +05:30
|
|
|
import os,string,subprocess
|
2013-01-29 20:58:21 +05:30
|
|
|
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
2013-02-01 17:51:56 +05:30
|
|
|
import damask
|
2013-01-29 20:58:21 +05:30
|
|
|
|
|
|
|
# -----------------------------
|
|
|
|
class extendedOption(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)
|
|
|
|
|
|
|
|
|
|
|
|
parser = OptionParser(option_class=extendedOption, usage='%prog [options] datafile[s]', description = """
|
|
|
|
Writes version specific files for different MARC releases, adjustes the make file for the spectral solver and optionally compiles the spectral solver
|
|
|
|
|
2013-02-03 14:52:25 +05:30
|
|
|
""" + string.replace('$Id$','\n','\\n')
|
2013-01-29 20:58:21 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
parser.add_option('-o', '--options', dest='makeOptions', action='extend', type='string', \
|
|
|
|
metavar="KEY=VALUE", \
|
2013-02-14 00:15:49 +05:30
|
|
|
help='comma-separated list of options passed to Makefile when compiling spectral code')
|
2013-01-29 20:58:21 +05:30
|
|
|
|
2013-02-14 00:15:49 +05:30
|
|
|
parser.set_defaults(makeOptions = ['F90='+{True:'ifort',False:'gfortran'}[\
|
|
|
|
subprocess.call(['which', 'ifort'],\
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0]])
|
2013-01-29 20:58:21 +05:30
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
damaskEnv = damask.Environment('../../') # script location relative to root
|
|
|
|
baseDir = damaskEnv.relPath('code/')
|
|
|
|
|
|
|
|
|
|
|
|
# compiling spectral code
|
2013-02-26 00:16:36 +05:30
|
|
|
print 'base directory:', baseDir
|
|
|
|
os.system('make --directory %s clean'%(baseDir))
|
|
|
|
print 'make options:',' '.join(options.makeOptions)
|
|
|
|
os.system('make --directory %s %s'%(baseDir,' '.join(options.makeOptions)))
|