diff --git a/config/acme/machines/template.case.run b/config/acme/machines/template.case.run index ea81a158527..d85c3e15dce 100755 --- a/config/acme/machines/template.case.run +++ b/config/acme/machines/template.case.run @@ -55,9 +55,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", help="Case directory to build") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/config/acme/machines/template.case.test b/config/acme/machines/template.case.test index 1c2cf6e49b0..81ccab9cbd1 100755 --- a/config/acme/machines/template.case.test +++ b/config/acme/machines/template.case.test @@ -50,9 +50,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", help="Case directory to build") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/config/acme/machines/template.lt_archive b/config/acme/machines/template.lt_archive index 421cca9325a..0feb5f9d377 100755 --- a/config/acme/machines/template.lt_archive +++ b/config/acme/machines/template.lt_archive @@ -49,9 +49,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", default=os.getcwd(), help="Case directory to build") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/config/acme/machines/template.st_archive b/config/acme/machines/template.st_archive index 68f008ab3f4..5f830a1e258 100755 --- a/config/acme/machines/template.st_archive +++ b/config/acme/machines/template.st_archive @@ -48,9 +48,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", default=os.getcwd(), help="Case directory to build") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/config/cesm/machines/template.case.run b/config/cesm/machines/template.case.run index 24162fe4595..7f9d31fc5f5 100755 --- a/config/cesm/machines/template.case.run +++ b/config/cesm/machines/template.case.run @@ -52,9 +52,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", help="Case directory to build") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/config/cesm/machines/template.case.test b/config/cesm/machines/template.case.test index e918de6ec21..13dbb65a4ce 100755 --- a/config/cesm/machines/template.case.test +++ b/config/cesm/machines/template.case.test @@ -46,9 +46,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", help="Case directory to build") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/config/cesm/machines/template.lt_archive b/config/cesm/machines/template.lt_archive index 1dd9de1a6bc..9f51cfa886f 100755 --- a/config/cesm/machines/template.lt_archive +++ b/config/cesm/machines/template.lt_archive @@ -47,9 +47,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", default=os.getcwd(), help="Case directory to build") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/config/cesm/machines/template.st_archive b/config/cesm/machines/template.st_archive index 0a1d935d5b0..ec2bc02de34 100755 --- a/config/cesm/machines/template.st_archive +++ b/config/cesm/machines/template.st_archive @@ -47,9 +47,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--caseroot", default=os.getcwd(), help="Case directory to build") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.caseroot is not None: os.chdir(args.caseroot) diff --git a/scripts/Tools/acme_check_env b/scripts/Tools/acme_check_env index 7abdbcf71fa..e6edf90576c 100755 --- a/scripts/Tools/acme_check_env +++ b/scripts/Tools/acme_check_env @@ -30,9 +30,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter CIME.utils.setup_standard_logging_options(parser) - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) ############################################################################### def check_sh(): diff --git a/scripts/Tools/bless_test_results b/scripts/Tools/bless_test_results index 4b01e4768f8..ceca60cf51f 100755 --- a/scripts/Tools/bless_test_results +++ b/scripts/Tools/bless_test_results @@ -89,9 +89,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("bless_tests", nargs="*", help="When blessing, limit the bless to tests matching these regex") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) expect(not (args.report_only and args.force), "Makes no sense to use -r and -f simultaneously") diff --git a/scripts/Tools/case.build b/scripts/Tools/case.build index 7fba3c18d61..8caee2ee579 100755 --- a/scripts/Tools/case.build +++ b/scripts/Tools/case.build @@ -56,9 +56,7 @@ OR parser.add_argument("--clean-all", action="store_true", help="clean all objects including sharedlibobjects that may be used by other builds") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) cleanlist = args.clean if args.clean is None or len(args.clean) else comps diff --git a/scripts/Tools/case.cmpgen_namelists b/scripts/Tools/case.cmpgen_namelists index e874121a205..999ba075a45 100755 --- a/scripts/Tools/case.cmpgen_namelists +++ b/scripts/Tools/case.cmpgen_namelists @@ -49,9 +49,7 @@ OR help="Force generation to use baselines with this name. " "Default will be to follow the case specification") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.caseroot, args.compare, args.generate, args.compare_name, args.generate_name diff --git a/scripts/Tools/case.setup b/scripts/Tools/case.setup index 3aca10bb130..7fb4eaae6da 100755 --- a/scripts/Tools/case.setup +++ b/scripts/Tools/case.setup @@ -45,9 +45,7 @@ OR parser.add_argument("-r", "--reset", action="store_true", help="Does a clean followed by setup") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.caseroot, args.clean, args.test_mode, args.reset diff --git a/scripts/Tools/case.submit b/scripts/Tools/case.submit index c307035dc43..3ea9d21b287 100755 --- a/scripts/Tools/case.submit +++ b/scripts/Tools/case.submit @@ -48,12 +48,10 @@ OR parser.add_argument("-a", "--batch-args", help="Used to pass additional arguments to batch system. ") - args = parser.parse_args(args[1:]) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) CIME.utils.expect(args.prereq is None, "--prereq not currently supported") - CIME.utils.handle_standard_logging_options(args) - return args.caseroot, args.job, args.no_batch, args.resubmit, args.batch_args ############################################################################### diff --git a/scripts/Tools/case_diff b/scripts/Tools/case_diff index 6cd5db1b706..4ad7da8da80 100755 --- a/scripts/Tools/case_diff +++ b/scripts/Tools/case_diff @@ -42,9 +42,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("-b", "--show-binary", action="store_true", help="Show binary diffs") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.case1, args.case2, args.show_binary, args.skip_list diff --git a/scripts/Tools/check_case b/scripts/Tools/check_case index 2553e1a197f..0c360e41e87 100755 --- a/scripts/Tools/check_case +++ b/scripts/Tools/check_case @@ -38,9 +38,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter CIME.utils.setup_standard_logging_options(parser) - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) ############################################################################### def _main_func(description): @@ -68,4 +66,3 @@ def _main_func(description): if __name__ == "__main__": _main_func(__doc__) - diff --git a/scripts/Tools/check_input_data b/scripts/Tools/check_input_data index 7795c063cac..dc127720490 100755 --- a/scripts/Tools/check_input_data +++ b/scripts/Tools/check_input_data @@ -52,9 +52,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("--download", action="store_true", help="Attempt to download missing input files") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.svn_loc, args.input_data_root, args.data_list_dir, args.download @@ -78,4 +76,3 @@ def _main_func(description): if (__name__ == "__main__"): _main_func(__doc__) - diff --git a/scripts/Tools/check_lockedfiles b/scripts/Tools/check_lockedfiles index 39b68a1bd90..46f509e4721 100755 --- a/scripts/Tools/check_lockedfiles +++ b/scripts/Tools/check_lockedfiles @@ -29,9 +29,7 @@ OR parser.add_argument("--caseroot", default=os.getcwd(), help="Case directory to build") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.caseroot diff --git a/scripts/Tools/cime_bisect b/scripts/Tools/cime_bisect index 6e2b37e93bd..53d1d830412 100755 --- a/scripts/Tools/cime_bisect +++ b/scripts/Tools/cime_bisect @@ -74,9 +74,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("-a", "--all-commits", action="store_true", help="Test all commits, not just merges") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if (args.test_root is None): args.test_root = os.path.join(_MACHINE.get_value("CIME_OUTPUT_ROOT"), "cime_bisect") diff --git a/scripts/Tools/code_checker b/scripts/Tools/code_checker index a81908a9951..79191d2d2bf 100755 --- a/scripts/Tools/code_checker +++ b/scripts/Tools/code_checker @@ -46,9 +46,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("files", nargs="*", help="Restrict checking to specific files. Relative name is fine.") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.num_procs, args.files diff --git a/scripts/Tools/compare_namelists b/scripts/Tools/compare_namelists index 69f86659afc..fcfbc481a2c 100755 --- a/scripts/Tools/compare_namelists +++ b/scripts/Tools/compare_namelists @@ -40,9 +40,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("-c", "--case", action="store", dest="case", default=None, help="The case base id (..). Helps us normalize data.") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) # Normalize case if (args.case is not None): diff --git a/scripts/Tools/compare_test_results b/scripts/Tools/compare_test_results index ae3ac037b14..7307c74e0c8 100755 --- a/scripts/Tools/compare_test_results +++ b/scripts/Tools/compare_test_results @@ -90,9 +90,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("compare_tests", nargs="*", help="When comparing, limit the comparison to tests matching these regex") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.baseline_name, args.baseline_root, args.test_root, args.compiler, args.test_id, args.compare_tests, args.namelists_only, args.hist_only diff --git a/scripts/Tools/component_compare_baseline b/scripts/Tools/component_compare_baseline index ea8e43343a7..a809e12acfe 100755 --- a/scripts/Tools/component_compare_baseline +++ b/scripts/Tools/component_compare_baseline @@ -35,9 +35,7 @@ OR parser.add_argument("-b", "--baseline-dir", help="Use custom baseline dir") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.caseroot, args.baseline_dir diff --git a/scripts/Tools/component_compare_copy b/scripts/Tools/component_compare_copy index 209358ff604..db3574cad57 100755 --- a/scripts/Tools/component_compare_copy +++ b/scripts/Tools/component_compare_copy @@ -36,9 +36,7 @@ OR parser.add_argument("caseroot", nargs="?", default=os.getcwd(), help="Case directory") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.suffix, args.caseroot diff --git a/scripts/Tools/component_compare_test b/scripts/Tools/component_compare_test index aae11911e49..07e6c17b199 100755 --- a/scripts/Tools/component_compare_test +++ b/scripts/Tools/component_compare_test @@ -38,9 +38,7 @@ OR parser.add_argument("caseroot", nargs="?", default=os.getcwd(), help="Case directory") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.suffix1, args.suffix2, args.caseroot diff --git a/scripts/Tools/component_generate_baseline b/scripts/Tools/component_generate_baseline index 0dcca7681c8..311537438df 100755 --- a/scripts/Tools/component_generate_baseline +++ b/scripts/Tools/component_generate_baseline @@ -40,9 +40,7 @@ OR "will raise an error. Specifying this option allows " "existing baseline directories to be silently overwritten.") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.caseroot, args.baseline_dir, args.allow_baseline_overwrite diff --git a/scripts/Tools/getTiming b/scripts/Tools/getTiming index a2ba123ec3b..22878582ee5 100755 --- a/scripts/Tools/getTiming +++ b/scripts/Tools/getTiming @@ -21,8 +21,8 @@ def parse_command_line(args, description): default="999999-999999") parser.add_argument("--caseroot", default=os.getcwd(), help="Case directory to get timing for") - args = parser.parse_args(args[1:]) - CIME.utils.handle_standard_logging_options(args) + + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.caseroot, args.lid def __main_func(description): diff --git a/scripts/Tools/jenkins_generic_job b/scripts/Tools/jenkins_generic_job index 5e4ae54369d..a31ff82fb8e 100755 --- a/scripts/Tools/jenkins_generic_job +++ b/scripts/Tools/jenkins_generic_job @@ -84,9 +84,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter help="Number of tasks create_test should perform simultaneously. Default " "will be min(num_cores, num_tests).") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) expect(not (args.submit_to_cdash and args.generate_baselines), "Does not make sense to use --generate-baselines and --submit-to-cdash together") diff --git a/scripts/Tools/list_acme_tests b/scripts/Tools/list_acme_tests index 915f0a380e1..c7f2cefba51 100755 --- a/scripts/Tools/list_acme_tests +++ b/scripts/Tools/list_acme_tests @@ -43,9 +43,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("categories", nargs="*", help="The test categories to list. Default will list all. Test categories: %s" % (", ".join(update_acme_tests.get_test_suites()))) - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if (not args.categories): args.categories = update_acme_tests.get_test_suites() diff --git a/scripts/Tools/normalize_cases b/scripts/Tools/normalize_cases index 1eca9367d5d..693c4861e67 100755 --- a/scripts/Tools/normalize_cases +++ b/scripts/Tools/normalize_cases @@ -38,9 +38,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("case2", help="Second case. This one will not be changed") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.case1, args.case2 diff --git a/scripts/Tools/pelayout b/scripts/Tools/pelayout index 64848d3a64e..50736a52832 100755 --- a/scripts/Tools/pelayout +++ b/scripts/Tools/pelayout @@ -68,9 +68,7 @@ def parse_command_line(args): parser.add_argument("-caseroot" , "--caseroot", default=os.getcwd(), help="Case directory to reference") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if (args.no_header): args.header = None diff --git a/scripts/Tools/preview_namelists b/scripts/Tools/preview_namelists index 2d3f8efcbf0..4bece0ee573 100755 --- a/scripts/Tools/preview_namelists +++ b/scripts/Tools/preview_namelists @@ -27,9 +27,7 @@ def parse_command_line(args, description): parser.add_argument('--test', action='store_true', help="Run preview_namelist in test mode.") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args diff --git a/scripts/Tools/save_provenance b/scripts/Tools/save_provenance index 885c55a4eb6..fa3ae37b869 100755 --- a/scripts/Tools/save_provenance +++ b/scripts/Tools/save_provenance @@ -42,9 +42,7 @@ OR parser.add_argument("-l", "--lid", help="Force system to save provenance with this LID") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.mode, args.caseroot, args.lid diff --git a/scripts/Tools/simple_compare b/scripts/Tools/simple_compare index 47b465c14fa..a72ebe398bc 100755 --- a/scripts/Tools/simple_compare +++ b/scripts/Tools/simple_compare @@ -40,9 +40,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("-c", "--case", action="store", dest="case", default=None, help="The case base id (..). Helps us normalize data.") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) # Normalize case if (args.case is not None): diff --git a/scripts/Tools/testreporter.py b/scripts/Tools/testreporter.py index 4ea6666dc24..bc5188ab41c 100755 --- a/scripts/Tools/testreporter.py +++ b/scripts/Tools/testreporter.py @@ -43,7 +43,7 @@ def parse_command_line(args): parser.add_argument("--dumpxml",action="store_true", help="Dump XML test results to sceen.") args = parser.parse_args() - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and_handle_standard_logging_options(args) return args.testroot, args.testid, args.tagname, args.testtype, args.dryrun, args.dumpxml diff --git a/scripts/Tools/update_acme_tests b/scripts/Tools/update_acme_tests index f5aeb4a0207..588c5132160 100755 --- a/scripts/Tools/update_acme_tests +++ b/scripts/Tools/update_acme_tests @@ -48,9 +48,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("-p", "--platform", help="Only add tests for a specific platform, format=machine,compiler. Useful for adding new platforms.") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) expect(os.path.isfile(args.test_list_path), "'%s' is not a valid file" % args.test_list_path) diff --git a/scripts/Tools/wait_for_tests b/scripts/Tools/wait_for_tests index 3e1b88d343f..7b4e698f3fa 100755 --- a/scripts/Tools/wait_for_tests +++ b/scripts/Tools/wait_for_tests @@ -66,9 +66,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("-g", "--cdash-build-group", default=CIME.wait_for_tests.CDASH_DEFAULT_BUILD_GROUP, help="The build group to be used to display results on the CDash dashboard.") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.paths, args.no_wait, args.check_throughput, args.check_memory, args.ignore_namelist_diffs, args.ignore_memleak, args.cdash_build_name, args.cdash_project, args.cdash_build_group diff --git a/scripts/Tools/xmlchange b/scripts/Tools/xmlchange index a8686fac4a0..f32bf556c0d 100755 --- a/scripts/Tools/xmlchange +++ b/scripts/Tools/xmlchange @@ -78,9 +78,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("-f","--force", action="store_true", help="ignore typing checks and store value") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) listofsettings = [] if( len(args.listofsettings )): diff --git a/scripts/Tools/xmlconvertors/config_pes_converter.py b/scripts/Tools/xmlconvertors/config_pes_converter.py index a0d0746c227..c453ee4c31b 100755 --- a/scripts/Tools/xmlconvertors/config_pes_converter.py +++ b/scripts/Tools/xmlconvertors/config_pes_converter.py @@ -28,9 +28,7 @@ def parse_command_line(args): parser.add_argument("-cime2file", "--cime2file", help="location of config_grid.xml file in CIME2 repository") parser.add_argument("-cime5file", "--cime5file", help="location of config_grids.xml file in CIME5 repository") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.cime2file is None or args.cime5file is None: parser.print_help() @@ -187,8 +185,8 @@ def __init__(self, xmlfilename): tempxml = StringIO.StringIO(t3) super(PesTree, self).__init__(tempxml) tempxml.close() - - + + def populate(self): xmlnodes = self.root.findall('grid') nodeclass = Cime5PesNode diff --git a/scripts/Tools/xmlconvertors/grid_xml_converter.py b/scripts/Tools/xmlconvertors/grid_xml_converter.py index 28fb95f49b5..988727a3edc 100755 --- a/scripts/Tools/xmlconvertors/grid_xml_converter.py +++ b/scripts/Tools/xmlconvertors/grid_xml_converter.py @@ -33,9 +33,7 @@ def parse_command_line(args): parser.add_argument("-cime2file", "--cime2file", help="location of config_grid.xml file in CIME2 repository") parser.add_argument("-cime5file", "--cime5file", help="location of config_grids.xml file in CIME5 repository") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.cime2file is None or args.cime5file is None: parser.print_help() diff --git a/scripts/Tools/xmlquery b/scripts/Tools/xmlquery index 95bb0996fc7..26b6b23d788 100755 --- a/scripts/Tools/xmlquery +++ b/scripts/Tools/xmlquery @@ -105,9 +105,7 @@ epilog=textwrap.dedent(__doc__)) group.add_argument("--valid-values", default=False, action="store_true", help="Print the valid values associated with this variable if defined") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if (len(sys.argv) == 1) : parser.print_help() diff --git a/scripts/create_clone b/scripts/create_clone index 968848a7a42..74c7bedfee5 100755 --- a/scripts/create_clone +++ b/scripts/create_clone @@ -40,9 +40,7 @@ def parse_command_line(args): help="Specify the root output directory" "default: setting in case, create_clone will fail if this directory is not writable") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.case is None: expect(False, diff --git a/scripts/create_newcase b/scripts/create_newcase index 1524e76d958..6d0f79cfcac 100755 --- a/scripts/create_newcase +++ b/scripts/create_newcase @@ -121,9 +121,7 @@ OR parser.add_argument("-i", "--input-dir", help="Use a non-default location for input files") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) if args.srcroot is not None: expect(os.path.isdir(args.srcroot), diff --git a/scripts/create_test b/scripts/create_test index 3ed88253cce..fb8ce394b44 100755 --- a/scripts/create_test +++ b/scripts/create_test @@ -226,9 +226,7 @@ OR parser.add_argument("-i", "--input-dir", help="Use a non-default location for input files") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) # generate and compare flags may not point to the same directory if model == "cesm": diff --git a/scripts/fortran_unit_testing/run_tests.py b/scripts/fortran_unit_testing/run_tests.py index 715a98f7fde..9ce19b2d453 100755 --- a/scripts/fortran_unit_testing/run_tests.py +++ b/scripts/fortran_unit_testing/run_tests.py @@ -127,8 +127,8 @@ def parse_command_line(args): "--xml-test-list", help="""Path to an XML file listing directories to run tests from.""" ) - args = parser.parse_args() - CIME.utils.handle_standard_logging_options(args) + + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) output = Printer(color=args.color) if args.xml_test_list is None and args.test_spec_dir is None: diff --git a/scripts/lib/CIME/XML/env_mach_specific.py b/scripts/lib/CIME/XML/env_mach_specific.py index 8e3ef188c71..e5d80ee4bdb 100644 --- a/scripts/lib/CIME/XML/env_mach_specific.py +++ b/scripts/lib/CIME/XML/env_mach_specific.py @@ -336,7 +336,7 @@ def get_mpirun(self, case, attribs, check_members=None, job="case.run", exe_only best_num_matched = -1 default_match = None best_num_matched_default = -1 - args = {} + args = [] for mpirun_node in mpirun_nodes: xml_attribs = mpirun_node.attrib all_match = True @@ -388,7 +388,7 @@ def get_mpirun(self, case, attribs, check_members=None, job="case.run", exe_only subgroup=job, check_members=check_members, default=arg_node.get("default")) - args[arg_node.get("name")] = arg_value + args.append(arg_value) exec_node = self.get_node("executable", root=the_match) expect(exec_node is not None,"No executable found") diff --git a/scripts/lib/CIME/buildlib.py b/scripts/lib/CIME/buildlib.py index 33b4ffce959..cc775e7bbbf 100644 --- a/scripts/lib/CIME/buildlib.py +++ b/scripts/lib/CIME/buildlib.py @@ -3,7 +3,7 @@ """ from CIME.XML.standard_module_setup import * -from CIME.utils import handle_standard_logging_options, setup_standard_logging_options +from CIME.utils import parse_args_and_handle_standard_logging_options, setup_standard_logging_options from CIME.case import Case import sys, os, argparse, doctest @@ -30,9 +30,7 @@ def parse_input(argv): parser.add_argument("bldroot", help="root for building library") - args = parser.parse_args() - - handle_standard_logging_options(args) + args = parse_args_and_handle_standard_logging_options(argv, parser) return args.caseroot, args.libroot, args.bldroot diff --git a/scripts/lib/CIME/buildnml.py b/scripts/lib/CIME/buildnml.py index 34f863155b6..0fa84fa578e 100644 --- a/scripts/lib/CIME/buildnml.py +++ b/scripts/lib/CIME/buildnml.py @@ -5,7 +5,7 @@ """ from CIME.XML.standard_module_setup import * -from CIME.utils import expect, handle_standard_logging_options, setup_standard_logging_options +from CIME.utils import expect, parse_args_and_handle_standard_logging_options, setup_standard_logging_options import sys, os, argparse, doctest logger = logging.getLogger(__name__) @@ -25,9 +25,7 @@ def parse_input(argv): parser.add_argument("caseroot", default=os.getcwd(), help="Case directory") - args = parser.parse_args() - - handle_standard_logging_options(args) + args = parse_args_and_handle_standard_logging_options(argv, parser) return args.caseroot diff --git a/scripts/lib/CIME/case.py b/scripts/lib/CIME/case.py index 9e143418fd5..8fc3d2b26a6 100644 --- a/scripts/lib/CIME/case.py +++ b/scripts/lib/CIME/case.py @@ -1129,21 +1129,21 @@ def get_mpirun_cmd(self, job="case.run"): "unit_testing" : False } - executable, args = env_mach_specific.get_mpirun(self, mpi_attribs, job=job) + executable, mpi_arg_list = env_mach_specific.get_mpirun(self, mpi_attribs, job=job) # special case for aprun - if executable is not None and "aprun" in executable: + if executable is not None and "aprun" in executable: aprun_args, num_nodes = get_aprun_cmd_for_case(self, run_exe) expect(num_nodes == self.num_nodes, "Not using optimized num nodes") return executable + aprun_args + " " + run_misc_suffix else: - mpi_arg_string = " ".join(args.values()) + mpi_arg_string = " ".join(mpi_arg_list) - if self.get_value("BATCH_SYSTEM") == "cobalt": - mpi_arg_string += " : " + if self.get_value("BATCH_SYSTEM") == "cobalt": + mpi_arg_string += " : " - return "%s %s %s" % (executable if executable is not None else "", mpi_arg_string, run_suffix) + return "%s %s %s" % (executable if executable is not None else "", mpi_arg_string, run_suffix) def set_model_version(self, model): version = "unknown" diff --git a/scripts/lib/CIME/case_setup.py b/scripts/lib/CIME/case_setup.py index f17ef584e07..dd815e39dce 100644 --- a/scripts/lib/CIME/case_setup.py +++ b/scripts/lib/CIME/case_setup.py @@ -155,7 +155,6 @@ def _case_setup_impl(case, caseroot, clean=False, test_mode=False, reset=False): logger.debug("at update TOTALPES = %s"%pestot) case.set_value("TOTALPES", pestot) thread_count = env_mach_pes.get_max_thread_count(models) - build_threaded = case.get_build_threaded() cost_pes = env_mach_pes.get_cost_pes(pestot, thread_count, machine=case.get_value("MACH")) case.set_value("COST_PES", cost_pes) diff --git a/scripts/lib/CIME/utils.py b/scripts/lib/CIME/utils.py index 247b04c6f61..6d79bce0543 100644 --- a/scripts/lib/CIME/utils.py +++ b/scripts/lib/CIME/utils.py @@ -637,7 +637,7 @@ def filter(self, record): #non-zero return means we log this message return 1 if record.levelno < self.max_level else 0 -def handle_standard_logging_options(args): +def parse_args_and_handle_standard_logging_options(args, parser=None): """ Guide to logging in CIME. @@ -660,6 +660,11 @@ def handle_standard_logging_options(args): stderr_stream_handler = logging.StreamHandler(stream=sys.stderr) stderr_stream_handler.setLevel(logging.WARNING) + # scripts_regression_tests is the only thing that should pass a None argument in parser + if parser is not None: + _check_for_invalid_args(args[1:]) + args = parser.parse_args(args[1:]) + # --verbose adds to the message format but does not impact the log level if args.verbose: stdout_stream_handler.setFormatter(verbose_formatter) @@ -682,6 +687,8 @@ def handle_standard_logging_options(args): root_logger.setLevel(logging.WARN) else: root_logger.setLevel(logging.INFO) + return args + def get_logging_options(): """ @@ -1229,6 +1236,16 @@ def run_and_log_case_status(func, phase, caseroot='.'): return rv +def _check_for_invalid_args(args): + for arg in args: + if arg.startswith("--"): + continue + if arg.startswith("-") and len(arg) > 2: + if arg == "-value" or arg == "-noecho": + logger.warn("This argument is depricated, please use -%s"%arg) + else: + expect(False, "Invalid argument %s\n Multi-character arguments should begin with \"--\" and single character with \"-\"\n Use --help for a complete list of available options"%arg) + class SharedArea(object): """ Enable 0002 umask within this manager diff --git a/scripts/manage_case b/scripts/manage_case index c561d6cede4..40f6a8fc280 100755 --- a/scripts/manage_case +++ b/scripts/manage_case @@ -140,9 +140,7 @@ def parse_command_line(args): parser.add_argument("--long", action="store_true", help="Provide long output for queries") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args diff --git a/scripts/manage_pes b/scripts/manage_pes index 6258b76e6d6..9f0f86e52cf 100755 --- a/scripts/manage_pes +++ b/scripts/manage_pes @@ -98,8 +98,8 @@ def parse_command_line(args, description): help=queryhelp) parser.add_argument("-machine", "--machine", default=None, help="can be a supported machine name") - args = parser.parse_args(args[1:]) - CIME.utils.handle_standard_logging_options(args) + + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) CIME.utils.expect(args.add or args.query, "Either --query or --add must be on command line") diff --git a/scripts/query_testlists b/scripts/query_testlists index 12d3fc0c3eb..d9c5f3a31d3 100755 --- a/scripts/query_testlists +++ b/scripts/query_testlists @@ -11,7 +11,7 @@ from CIME.utils import expect logger = logging.getLogger(__name__) ############################################################################### -def parse_command_line(description): +def parse_command_line(args, description): ############################################################################### parser = argparse.ArgumentParser( description=description) @@ -45,9 +45,7 @@ def parse_command_line(description): parser.add_argument("--xml-testlist", help="Use this testlist to lookup tests, default specified in config_files.xml") - args = parser.parse_args() - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) expect(not(args.count and args.list_type), "Cannot specify both --count and --list arguments.") @@ -149,7 +147,7 @@ def list_test_data(test_data, list_type): ############################################################################### def _main_func(description): ############################################################################### - args = parse_command_line(description) + args = parse_command_line(sys.argv, description) test_data = get_tests_from_xml( xml_machine = args.xml_machine, diff --git a/scripts/tests/scripts_regression_tests.py b/scripts/tests/scripts_regression_tests.py index 7dac780e46d..380b0f19fdf 100755 --- a/scripts/tests/scripts_regression_tests.py +++ b/scripts/tests/scripts_regression_tests.py @@ -2217,7 +2217,7 @@ def _main_func(): else: setattr(args, log_param, False) - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, None) write_provenance_info() diff --git a/src/build_scripts/buildlib.gptl b/src/build_scripts/buildlib.gptl index 2a5fea6f852..b92c788d396 100755 --- a/src/build_scripts/buildlib.gptl +++ b/src/build_scripts/buildlib.gptl @@ -6,8 +6,8 @@ cd $CASEROOT # CASEROOT is always assumed to be an environment variable -set CIMEROOT = `./xmlquery CIMEROOT -value ` -set GMAKE = `./xmlquery GMAKE -value ` +set CIMEROOT = `./xmlquery CIMEROOT -value ` +set GMAKE = `./xmlquery GMAKE --value ` # NOTE- (mv, 2015-01-02) SHAREDPATH is an environment variable set in # the $CASE.build script diff --git a/src/build_scripts/buildlib.pio b/src/build_scripts/buildlib.pio index cb4d29e40bf..5b6909b0ddf 100755 --- a/src/build_scripts/buildlib.pio +++ b/src/build_scripts/buildlib.pio @@ -38,9 +38,7 @@ formatter_class=argparse.ArgumentDefaultsHelpFormatter parser.add_argument("caseroot", nargs="?", default=os.getcwd(), help="Case directory to build") - args = parser.parse_args(args[1:]) - - CIME.utils.handle_standard_logging_options(args) + args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser) return args.buildroot, args.installpath, args.caseroot @@ -144,7 +142,7 @@ def _main_func(description): case.set_valid_values("PIO_TYPENAME",valid_values) # nothing means use the general default valid_values += ",nothing" - + for comp in case.get_values("COMP_CLASSES"): comp_pio_typename = "%s_PIO_TYPENAME"%comp case.set_valid_values(comp_pio_typename,valid_values) diff --git a/tools/configure b/tools/configure index bba14b82d70..997b1d3e524 100755 --- a/tools/configure +++ b/tools/configure @@ -69,7 +69,7 @@ def parse_command_line(args): argcnt = len(args) args = parser.parse_args() - CIME.utils.handle_standard_logging_options(args) + CIME.utils.parse_args_and_handle_standard_logging_options(args) opts = {} if args.machines_dir is not None: