forked from ESMCI/cime
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathcreate_clone
More file actions
executable file
·90 lines (67 loc) · 4.37 KB
/
Copy pathcreate_clone
File metadata and controls
executable file
·90 lines (67 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python
from Tools.standard_script_setup import *
from CIME.utils import expect
from CIME.case import Case
from argparse import RawTextHelpFormatter
logger = logging.getLogger(__name__)
###############################################################################
def parse_command_line(args):
###############################################################################
parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter)
CIME.utils.setup_standard_logging_options(parser)
parser.add_argument("--case", "-case", required=True,
help="(required) Specify a new case name. If not a full pathname, "
"\nthe new case will be created under then current working directory.")
parser.add_argument("--clone", "-clone", required=True,
help="(required) Specify a case to be cloned. If not a full pathname, "
"\nthe case to be cloned is assumed to be under then current working directory.")
parser.add_argument("--user-mods-dir",
help="Full pathname to a directory containing any combination of user_nl_* files "
"\nand shell_commands script (typically containing xmlchange commands). "
"\nThe directory can also contain an SourceMods/ directory with the same structure "
"\nas would be found in a case directory. If this argument is used in conjunction "
"\nwith the --keepexe flag, then no changes will be permitted to the env_build.xml "
"\nin the newly created case directory. ")
parser.add_argument("--keepexe", "-keepexe", action="store_true",
help="Sets EXEROOT to point to original build. It is HIGHLY recommended "
"\nthat the original case be built BEFORE cloning it if the --keepexe flag is specfied. "
"\nThis flag will make the SourceMods/ directory in the newly created case directory a "
"\nsymbolic link to the SourceMods/ directory in the original case directory. ")
parser.add_argument("--mach-dir", "-mach_dir",
help="Specify the locations of the Machines directory, other than the default. "
"\nThe default is CIMEROOT/machines.")
parser.add_argument("--project", "-project",
help="Specify a project id for the case (optional)."
"\nUsed for accounting and directory permissions when on a batch system."
"\nThe default is user or machine specified by PROJECT."
"\nAccounting (only) may be overridden by user or machine specified CHARGE_ACCOUNT.")
parser.add_argument("--cime-output-root",
help="Specify the root output directory. The default is the setting in the original"
"\ncase directory. NOTE: create_clone will fail if this directory is not writable.")
args = CIME.utils.parse_args_and_handle_standard_logging_options(args, parser)
if args.case is None:
expect(False,
"Must specify -case as an input argument")
if args.clone is None:
expect(False,
"Must specify -clone as an input argument")
return args.case, args.clone, args.keepexe, args.mach_dir, args.project, \
args.cime_output_root, args.user_mods_dir
##############################################################################
def _main_func():
###############################################################################
case, clone, keepexe, mach_dir, project, cime_output_root, user_mods_dir = parse_command_line(sys.argv)
cloneroot = os.path.abspath(clone)
expect(os.path.isdir(cloneroot),
"Missing cloneroot directory %s " % cloneroot)
if user_mods_dir is not None:
if os.path.isdir(user_mods_dir):
user_mods_dir = os.path.abspath(user_mods_dir)
with Case(cloneroot, read_only=False) as clone:
clone.create_clone(case, keepexe=keepexe, mach_dir=mach_dir,
project=project,
cime_output_root=cime_output_root,
user_mods_dir=user_mods_dir)
###############################################################################
if __name__ == "__main__":
_main_func()