#!/usr/bin/env python """ preview_namelists runs the buildnml script for each case component which creates the namelist and other model input files, it then copies those files to the CaseDocs subdirectory for inspection """ from standard_script_setup import * from CIME.preview_namelists import create_namelists from CIME.case import Case from CIME.utils import expect import argparse, doctest ############################################################################### def parse_command_line(args, description): ############################################################################### parser = argparse.ArgumentParser( usage="""\n%s [--debug] OR %s --verbose OR %s --help OR %s --test \033[1mEXAMPLES:\033[0m \033[1;32m# Run \033[0m > %s """ % ((os.path.basename(args[0]), ) * 5), description=description, formatter_class=argparse.ArgumentDefaultsHelpFormatter ) CIME.utils.setup_standard_logging_options(parser) 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) return args.caseroot ############################################################################### def _main_func(description): ############################################################################### if ("--test" in sys.argv): test_results = doctest.testmod(verbose=True) sys.exit(1 if test_results.failed > 0 else 0) caseroot = parse_command_line(sys.argv, description) expect(os.path.isfile(os.path.join(caseroot, "CaseStatus")), "case.setup must be run prior to running preview_namelists") with Case(caseroot, read_only=False) as case: create_namelists(case) if (__name__ == "__main__"): _main_func(__doc__)