52 import os, sys, re, logging, collections
54 if 'USHhwrf' in os.environ:
55 sys.path.append(os.environ[
'USHhwrf'])
56 elif 'HOMEhwrf' in os.environ:
57 sys.path.append(os.path.join(os.environ[
'HOMEhwrf'],
'ush'))
59 guess_HOMEhwrf=os.path.dirname(os.path.dirname(
60 os.path.realpath(__file__)))
61 guess_USHhwrf=os.path.join(guess_HOMEhwrf,
'ush')
62 sys.path.append(guess_USHhwrf)
75 # Holdvars file with ksh variables:
84 # Three character storm ID -- just number and basin letter:
85 stormid3="{vit[stormid3]}"
88 longstormid="{vit[longstormid]}"
92 logger.critical(
'Invalid arguments to exhwrf_launch.py. Aborting.')
94 Usage: exhwrf_launch.py 2014062400 95E case_root /path/to/parm [options]
97 2014062400 -- the cycle to run
99 case_root -- FORECAST = real-time mode, HISTORY = retrospective mod
100 /path/to/parm -- location of parm directory where standard conf files
104 section.option=value -- override conf options on the command line
105 /path/to/file.conf -- additional conf files to parse
107 Aborting due to incorrect arguments.'''
111 """!Processes configuration information and passes on to the
112 hwrf.launcher module to create the initial directory structure and
114 logger=logging.getLogger(
'exhwrf_launch')
115 PARAFLAG = (
'YES' == os.environ.get(
'PARAFLAG',
'YES') )
116 logger.info(
'Top of exhwrf_launch.')
121 if len(args)<4: usage(logger)
124 cycle=to_datetime(args[0])
128 go_since_multistorm_sids =
False
131 basins = os.environ.get(
'BASINS',
None)
132 multi_sids_env = os.environ.get(
'MULTISTORM_SIDS',
'')
135 multi_sids = [s
for s
in multi_sids_env.split()]
136 if basins
is not None:
137 go_since_multistorm_sids =
True
138 logger.info(
'Looks like this is rocoto, running a multistorm with basins: %s'%(basins))
141 logger.info(
'Priority found the following storms: ' +repr(bstorms))
143 if s
not in multi_sids:
146 logger.info(
'MS LIST: ' +repr(multi_sids))
149 go_since_multistorm_sids =
True
150 fakestorm_conf =
None
152 if go_since_multistorm_sids:
153 logger.info(
'Parsing input arguments for a multistorm with ids: %s.'% (multi_sids))
154 (case_root, parm, infiles, stids, fake_stid, priority_stid, moreopts) = \
159 prelaunch=hwrf_expt.prelaunch,
162 (case_root,parm,infiles,stid,moreopt) = \
167 logger.info(
'Requested storm %s cycle %s case root %s'
168 %(stid,cycle.strftime(
'%Y%m%d%H'),case_root))
171 for i,stid
in enumerate(stids):
172 if stid != fake_stid:
174 prelaunch=hwrf_expt.prelaunch,
175 fakestorm_conf=fakestorm_conf,
176 storm_num=global_storm_num)
180 global_storm_num += 1
183 if 'NO'==os.environ.get(
'PARAFLAG',
'YES'):
184 message=conf.strinterp(
'wcoss_fcst_nco',
'{messages}/message{storm_num}')
185 if os.path.exists(message):
190 holdvars=conf.strinterp(
'dir',
'{com}/{stormlabel}.holdvars.txt')
191 logger.info(holdvars+
': write holdvars here')
192 with open(holdvars,
'wt')
as f:
193 f.write(conf.make_holdvars())
195 if conf.has_option(
'config',
'startfile'):
196 startfile=conf.getstr(
'config',
'startfile')
197 logger.info(startfile+
': Write holdvars and conf location here.')
198 startcontents=conf.strinterp(
'config',startdata,holdvars=holdvars)
199 with open(startfile,
'wt')
as f:
200 f.write(startcontents)
203 if __name__ ==
'__main__':
209 except Exception
as e:
210 produtil.log.jlogger.critical(
211 'exhwrf_launch failed: %s'%(str(e),),exc_info=
True)
Contains setup(), which initializes the produtil package.
def postmsg(message)
Sends the message to the jlogfile logging stream at level INFO.
def setup(ignore_hup=False, dbnalert_logger=None, jobname=None, cluster=None, send_dbn=None, thread_logger=False, thread_stack=2 **24, kwargs)
Initializes the produtil package.
def parse_launch_args
Parsed arguments to scripts that launch the HWRF system.
def launch
Initializes the directory structure for a new HWRF workflow.
Time manipulation and other numerical routines.
This module runs the NCO dbn_alert program, or logs dbn_alert messages if run with dbn alerts disable...
This class represents a call to dbn_alert, as a callable Python object.
Creates the initial HWRF directory structure, loads information into each job.
def multistorm_parse_args
def main()
Processes configuration information and passes on to the hwrf.launcher module to create the initial d...