Commit 2a0687cf authored by Thomas Dubos's avatar Thomas Dubos
Browse files

Fix argument parsing

parent df413dfd
Pipeline #169241 passed with stages
in 9 minutes and 16 seconds
......@@ -2,9 +2,12 @@ from __future__ import print_function
import argparse
import logging
def init_parser(options):
global parser
parser = argparse.ArgumentParser(conflict_handler='resolve')
parser = argparse.ArgumentParser(conflict_handler='resolve')
parse, add_argument = parser.parse_args, parser.add_argument
add_argument("--debug", default=[], type=lambda str : str.split(','),
help='Comma-separated list of modules that will display debug information')
def add_default_args(options):
def add(option, *args, **kwargs):
if option in options:
parser.add_argument(option, *args, **kwargs)
......@@ -13,9 +16,6 @@ def init_parser(options):
add("--hydrostatic", action='store_true')
add("--llm", type=int)
add("--dt", type=float, help='Time step in seconds')
add("--debug", default=[], type=lambda str : str.split(','),
help='Comma-separated list of modules that will display debug information')
return parser.add_argument, parser.parse_args
def noop(*args, **kwargs): pass
......@@ -27,7 +27,7 @@ def getLogger(modulename='dynamico.main'):
# two logger are created
# the 'master' logger will be muted if current MPI process is not master
# log your messages through master two avoid massive logs with 1000+ MPI processes
global parser
# global parser
arglist = parser.parse_args()
master, world = logging.getLogger(modulename), logging.getLogger('%s.world'%modulename)
debug=False
......
from . import getargs
def parse_args():
add, parse = getargs.init_parser(['--mpi_ni','--mpi_nj','--debug'])
getargs.add_default_args(['--mpi_ni','--mpi_nj','--debug'])
add = getargs.add_argument
add("--LAM", action='store_true')
# Args for both cases
add("--Omega", type=float, help='Planetary radius', default=7.292e-5)
......@@ -18,7 +20,7 @@ def parse_args():
add("--center_lat", type=float, help='Latitude in degrees of LAM center', default=0.)
add("--Davies_N1", type=int, default=3)
add("--Davies_N2", type=int, default=3)
return parse()
return getargs.parse()
args = parse_args() # must be called before getLogger
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment