diff --git a/CIME/scripts/create_newcase.py b/CIME/scripts/create_newcase.py index 3faea5d6553..eb82d392994 100755 --- a/CIME/scripts/create_newcase.py +++ b/CIME/scripts/create_newcase.py @@ -239,6 +239,8 @@ def parse_command_line(args, cimeroot, description): parser.add_argument( "--driver", + # use get_cime_default_driver rather than config.driver_default as it considers + # environment, user config then config.driver_default default=get_cime_default_driver(), choices=drv_choices, help=drv_help, diff --git a/CIME/scripts/create_test.py b/CIME/scripts/create_test.py index 44ccb1687be..65fcc03b359 100755 --- a/CIME/scripts/create_test.py +++ b/CIME/scripts/create_test.py @@ -219,7 +219,7 @@ def parse_command_line(args, description): parser.add_argument( "--driver", - choices=("mct", "nuopc", "moab"), + choices=model_config.driver_choices, help="Override driver specified in tests and use this one.", ) diff --git a/CIME/scripts/query_config.py b/CIME/scripts/query_config.py index 674713e0485..88d2151d1c1 100755 --- a/CIME/scripts/query_config.py +++ b/CIME/scripts/query_config.py @@ -8,7 +8,7 @@ from CIME.Tools.standard_script_setup import * import re -from CIME.utils import expect +from CIME.utils import expect, get_cime_default_driver, deprecate_action from CIME.XML.files import Files from CIME.XML.component import Component from CIME.XML.compsets import Compsets @@ -314,8 +314,16 @@ def parse_command_line(args, description): parser.add_argument( "--comp_interface", - choices=supported_comp_interfaces, + choices=supported_comp_interfaces, # same as config.driver_choices default="mct", + action=deprecate_action(", use --driver argument"), + help="DEPRECATED: Use --driver argument", + ) + + parser.add_argument( + "--driver", + choices=config.driver_choices, + default=get_cime_default_driver(), help="Coupler/Driver interface", ) @@ -332,7 +340,7 @@ def parse_command_line(args, description): args.machines, args.long, args.xml, - files[args.comp_interface], + files[args.driver], ) diff --git a/CIME/utils.py b/CIME/utils.py index b79fcd5116e..4f0e133ae73 100644 --- a/CIME/utils.py +++ b/CIME/utils.py @@ -8,6 +8,7 @@ import importlib.util import errno, signal, warnings, filecmp import stat as statlib +from argparse import Action from contextlib import contextmanager from distutils import file_util @@ -21,6 +22,14 @@ GLOBAL = {} +def deprecate_action(message): + class ActionStoreDeprecated(Action): + def __call__(self, parser, namespace, values, option_string=None): + raise DeprecationWarning(f"{option_string} is deprecated{message}") + + return ActionStoreDeprecated + + def import_from_file(name, file_path): loader = importlib.machinery.SourceFileLoader(name, file_path)