-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathldas_setup
More file actions
executable file
·178 lines (158 loc) · 5.56 KB
/
ldas_setup
File metadata and controls
executable file
·178 lines (158 loc) · 5.56 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python3
import sys
import argparse
import resource
from setup_utils import *
from ldas import *
def parseCmdLine():
"""
parse command line arguments and return a dict of options
"""
#print 'in: parseCmdLine'
p = argparse.ArgumentParser(
description= \
"Script to setup a GEOSldas experiment. "\
"To set up an *offline* GEOSldas experiment, the script requires "\
"two (2) input files, one for the experiment inputs ('exeinp') and the "\
"other for the (SLURM) resource manager ('batinp'). To create sample input "\
"files use './ldas_setup sample -h'. "\
"When used to set up a coupled land-atm DAS experiment, the script "\
"*ignores* the input files, but dummy strings must still be specified. ",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
p_sub = p.add_subparsers(help='sub-command help')
# subparser: "sample" command
p_sample = p_sub.add_parser(
'sample',
help='write sample input files',
description='Print sample input files - either for the '\
'experiment inputs or the resource manager (SLURM)',
)
group = p_sample.add_mutually_exclusive_group(required=True)
group.add_argument(
'--exeinp',
help='print sample input file used to generate RC files for GEOSldas App.',
action='store_true',
)
group.add_argument(
'--batinp',
help='print sample input file for the resource manager (SLURM)',
action='store_true',
)
# subparser: "setup" command
p_setup = p_sub.add_parser(
'setup',
help='setup LDAS experiment',
description="The 'setup' sub-command is used to set up a GEOSldas " \
"experiment. The positional argument 'exphome' is used to create " \
"work_path (=exphome+/output) and run_path (=exphome+/run)."
)
p_setup.add_argument(
'-v',
'--verbose',
help='verbose output',
action='store_true',
)
p_setup.add_argument('exphome', help='experiment location')
p_setup.add_argument(
'exeinpfile',
help='input file with arguments used to generate RC files for GEOSldas App',
)
p_setup.add_argument(
'batinpfile',
help='input file with arguments for SLURM',
)
# the following command line arguments, if present, take precedence over what
# is specified in the exeinp and batinp files
ladas_cpl_help='land-atm DAS coupling mode: default=0 (not coupled); LDAS coupled with (1) ADAS deterministic member or (2) ADAS ensemble. Required when exeinp is dummy'
p_setup.add_argument(
'--ladas_cpl',
help=ladas_cpl_help,
type=str
)
p_setup.add_argument(
'--account',
help='overwrites computing/sponsor account from batinp file',
type=str
)
p_setup.add_argument(
'--nymdb',
help='overwrites date in BEG_DATE from exeinp file: yyyymmdd. Required when exeinp is dummy',
type=str
)
p_setup.add_argument(
'--nhmsb',
help='overwrites time in BEG_DATE from exeinp file: hhmmss. Required when exeinp is dummy',
type=str
)
p_setup.add_argument(
'--agcm_res',
help='AGCM resolution associated with boundary conditions: nnnn (4 digits). Required when exeinp is dummy',
type=str
)
p_setup.add_argument(
'--bcs_version',
help='boundary conditions version. Required when exeinp is dummy',
type=str
)
p_setup.add_argument(
'--rstloc',
help='location of LDAS restarts (restart_path/restart_id). Required when exeinp is dummy',
type=str
)
p_setup.add_argument(
'--varwindow',
help='ADAS analysis window (minutes). Required when exeinp is dummy',
type=str
)
p_setup.add_argument(
'--nens',
help='number of ensemble members. Required when exeinp is dummy',
type=str
)
# obsolete command line args
p_setup.add_argument(
'--runmodel',
help='Obsolete.',
action='store_true',
)
spltgrp = p_setup.add_mutually_exclusive_group()
spltgrp.add_argument(
'--daysperjob',
type=int,
metavar='N',
help='Obsolete. Use NUM_SGMT and JOB_SGMT in exeinp file.',
)
spltgrp.add_argument(
'--monthsperjob',
type=int,
metavar='N',
help='Obsolete. Use NUM_SGMT and JOB_SGMT in exeinp file.',
)
return p.parse_args()
if __name__=='__main__':
resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY))
#convert command line to dictionary
args = vars(parseCmdLine())
#./ldas_setup sample sub-command
# print input sample file then exit
if 'exeinp' in args:
printInputSampleFile(args)
sys.exit(0)
# start ./ldas_setup setup sub-command
ldasObj = ldas(args)
print ("creating dir structure")
status = ldasObj.createDirStructure()
assert(status)
print ("creating links to restarts, BCs, met forcing, ...")
status = ldasObj.createLnRstBc()
assert(status)
print ("creating RC Files")
status = ldasObj.createRCFiles()
assert(status)
print ("creating gcm style batch Run scripts lenkf.j")
status = ldasObj.createRunScripts()
assert(status)
print ("creating batch Run scripts")
status = ldasObj.createBatchRun()
assert (status)