2013-01-29 20:58:21 +05:30
|
|
|
#!/usr/bin/env python
|
2013-02-01 17:51:56 +05:30
|
|
|
|
|
|
|
import os,string
|
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('-c', '--compile', dest='spectralCompile', action='store_true', \
|
|
|
|
help='compiles the spectral solver [%default]')
|
|
|
|
parser.add_option('-o', '--options', dest='makeOptions', action='extend', type='string', \
|
|
|
|
metavar="KEY=VALUE", \
|
|
|
|
help='comma-separated list of options passed to Makefile when compiling spectral code %default')
|
|
|
|
parser.set_defaults(spectralCompile = True)
|
|
|
|
parser.set_defaults(makeOptions = ['F90=ifort'])
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
damaskEnv = damask.Environment('../../') # script location relative to root
|
|
|
|
baseDir = damaskEnv.relPath('code/')
|
|
|
|
|
|
|
|
|
|
|
|
# compiling spectral code
|
|
|
|
if (options.spectralCompile):
|
|
|
|
print 'base directory', baseDir
|
|
|
|
os.system('make --directory %s clean'%(baseDir))
|
|
|
|
print options.makeOptions
|
|
|
|
os.system('make --directory %s %s'%(baseDir,' '.join(options.makeOptions)))
|