37,743
社区成员
发帖
与我相关
我的任务
分享def checkrun(arg,logger=None,**kwargs):
"""!This is a simple wrapper round run that raises
ExitStatusException if the program exit status is non-zero.
@param arg the produtil.prog.Runner to execute (output of
exe(), bigexe() or mpirun()
@param logger a logging.Logger to log messages
@param kwargs The optional run=[] argument can provide a different
list of acceptable exit statuses."""
r=run(arg,logger=logger)
if kwargs is not None and 'ret' in kwargs:
if not r in kwargs['ret']:
raise ExitStatusException('%s: unexpected exit status'%(repr(arg),),r)
elif not r==0:
raise ExitStatusException('%s: non-zero exit status'%(repr(arg),),r) #第415行
return rclass Geogrid(WPSTask):
.....
def run(self):
"""!Copies inputs, links fix files, runs geogrid and delivers
results."""
logger=self.log()
try:
produtil.fileop.makedirs(self.outdir)
with NamedDir(self.location) as dir:
logger.info('Geogrid running in directory: '+os.getcwd())
assert(not re.match('\A/tmp',os.getcwd()))
for f in glob.glob('geo*'):
try:
produtil.fileop.remove_file(f,logger=logger)
except(EnvironmentError) as e:
logger.warning('%s: did not remove file, but '
'continuing anyway'%(f,))
self.link_fix(geog_data=True,table='GEOGRID.TBL')
with open('namelist.wps', 'w') as f:
f.write(self.make_namelist())
prog = self.getexe('hwrf_geogrid')
log = self._section + '.log'
cmd = produtil.run.mpirun(produtil.run.mpi(prog),
allranks=True)
if self.redirect: cmd=cmd > log
logger.info('%s command: %s'%(self.taskname, repr(cmd),))
produtil.run.checkrun(cmd,logger=logger) #第635行
findme="Successful completion"
geogrid_log=None
for glog in ( 'geogrid.log', 'geogrid.log.0000',
'geogrid.log.00000' ):
if os.path.exists(glog):
geogrid_log=glog
else:
logger.info('%s: does not exist.'%(glog,))
if geogrid_log is None:
msg='WPS Geogrid failed: could not find geogrid log file.'
logger.error(msg)
self.state=FAILED
raise GeogridNoLog(msg)
logger.info('%s: will check for %s'%(geogrid_log,findme))
if not check_last_lines(geogrid_log,findme):
raise WPSError('%s: did not find "%s"'
%(geogrid_log,findme))
self.deliver_products(keep=False,relink=True)class HWRFInit(HWRFTask):
......
def run_through_anl(self):
"""!Runs the following jobs, if they are enabled: geogrid,
ungrib, metgrid, init-length prep_hybrid, init-length real_nmm
and wrfanl."""
self.log().warning('run_through_anl')
if 'geogrid' in self.__dict__:
set_ecflow_label('status','[geogrid] process terrain')
self.geogrid.run() #第559行
set_ecflow_label('status','[ungrib] process parent GRIB')
self.ungrib.run()
set_ecflow_label('status','[metgrid] interpolate horizontally')
self.metgrid.run()
if 'prep' in self.__dict__:
set_ecflow_label('status','[prep] process parent spectral')
for i in xrange(len(self.ibdytimes)):
t=self.ibdytimes[i]
if t>self.initlen: break
self.prep.run_ipiece(i)
set_ecflow_label('status','[realinit] make wrfinput file')
self.realinit.run()
set_ecflow_label('status','[runwrfanl] make wrfanl files')
self.runwrfanl.run()
set_ecflow_label('status','Passed through anl.')