18 __all__=[
'Hwrf',
'Oceanini',
'fbtr',
'g3',
'na',
'phase',
'pget',
'prun',
'psend' ]
26 from os.path
import join
as jn2r
28 from produtil.fileop import deliver_file, makedirs, make_symlink, rmall, isnonempty
29 from produtil.run import mpi, mpirun, checkrun, run, exe , openmp, runsync
30 from util
import ysplitter, inpfile, logi2int
31 from exceptions
import *
32 from check_lcfiles
import Isthis_LCuseful
35 """!Abstract base class that stores data relating to the HWRF
36 workflow in which the POM initialization resides."""
37 def __init__(self,STORMNAME,STORMID,STARTDATE,EXEChwrf,PARMhwrf,
38 FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
39 sync_frequently=
False):
41 @param STORMNAME Upper-case storm name for filenames (KATRINA)
42 @param STORMID Three character storm number and basin, upper-case (12L)
43 @param STARTDATE Simulation analysis time as a string, YYYYMMDDHH (2005082918)
44 @param EXEChwrf Directory with HWRF executables.
45 @param PARMhwrf Directory with HWRF parameter files.
46 @param FIXhwrf Directory with HWRF fixed files.
47 @param LCDIR Directory with loop current files
48 @param GFSDIR Directory with input files from GFS.
49 @param CSTREAM Directory to place files for the POM forecast to read.
50 @param COMIN HWRF final output directory.
52 @param sync_frequently If True, run "sync" frequently"""
61 assert(self.GFSDIR.find(
'pom/output')<0)
97 """!Parent class of POM initialization classes."""
98 def __init__(self,ODIR,DOMAIN,ODATA,SSTASIM,STORMNAME,STORMID,STARTDATE,EXEChwrf,PARMhwrf,
99 FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
100 sync_frequently=
False,**kwargs):
101 """!Oceanini constructor
102 @param ODIR Ocean output directory in CSTREAM
103 @param SSTASIM SST ASIM flag, True or False
104 @param DOMAIN Ocean domain.
105 @param ODATA Type of ocean data.
106 @param STORMNAME Upper-case storm name for filenames (KATRINA)
107 @param STORMID Three character storm number and basin, upper-case (12L)
108 @param STARTDATE Simulation analysis time as a string, YYYYMMDDHH (2005082918)
109 @param EXEChwrf Directory with HWRF executables.
110 @param PARMhwrf Directory with HWRF parameter files.
111 @param FIXhwrf Directory with HWRF fixed files.
112 @param LCDIR Directory with loop current files
113 @param GFSDIR Directory with input files from GFS.
114 @param CSTREAM Directory to place files for the POM forecast to read.
115 @param COMIN HWRF final output directory.
116 @param sync_frequently if True, run "sync" frequently
117 @param kwargs Can optionally contain conf, which should point
118 to a ConfigParser-like object to use for configuration
119 information. An hwrf.config.HWRFConfig is acceptable for
121 assert(GFSDIR.find(
'pom/output')<0)
122 super(Oceanini,self).
__init__(STORMNAME,STORMID,STARTDATE,EXEChwrf,PARMhwrf,
123 FIXhwrf,LCDIR,GFSDIR,CSTREAM,COMIN,
124 sync_frequently=sync_frequently)
129 self.
conf = kwargs.pop(
'conf',
None)
148 """!Creates the ocean run path, whose subdirectory is SUBDIR.
149 @param SUBDIR the subdirectory to create
150 @returns a tuple (rundir,finaldir) where rundir is CSTREAM+'/'+ODIR
151 and finaldir is the SUBDIR subdirectory of that """
154 if SUBDIR !=
"" and os.path.exists(RUNDIR)
and \
155 not os.path.exists(RUNDIR+
"/"+SUBDIR):
156 makedirs(RUNDIR+
"/"+SUBDIR)
157 if not os.path.exists(RUNDIR):
159 return (RUNDIR,RUNDIR+
"/"+SUBDIR)
161 raise IOError(
'CSTREAM does NOT exist.')
164 """!Runs the FBTR (feature-based) initialization of the MPIPOMTC."""
167 @param args,kargs passed to Oceanini.__init__()"""
168 super(fbtr,self).
__init__(*args,**kargs)
170 """!Links or copies input files.
172 @param DEST The directory in which to link or copy files.
173 @param logger A logging.Logger for log messages."""
174 if logger
is None: logger=logging.getLogger(
'pom')
176 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
177 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sfcanl"),jn2r(DEST,
"fort.11"),
True,logger=logger)
178 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sfcanl"),jn2r(DEST,
"for11"),
True,logger=logger)
179 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sanl"),jn2r(DEST,
"fort.12"),
True,logger=logger)
180 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_topo_and_mask.united"),
181 jn2r(DEST,
"fort.66"),
True,logger=logger)
182 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_gdem."+mm+
".ascii"),
183 jn2r(DEST,
"fort.8"),
True,logger=logger)
184 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_gdem."+mm1+
".ascii"),
185 jn2r(DEST,
"fort.90"),
True,logger=logger)
186 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_readu.dat."+mm),
187 jn2r(DEST,
"fort.24"),
True,logger=logger)
188 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_spinup_gdem3.dat."+mm),
189 jn2r(DEST,
"fort.82"),
True,logger=logger)
190 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_spinup_gspath."+mm),
191 jn2r(DEST,
"fort.50"),
True,logger=logger)
192 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_spinup.BAYuf"),
193 jn2r(DEST,
"fort.55"),
True,logger=logger)
194 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_spinup.FSgsuf"),
195 jn2r(DEST,
"fort.65"),
True,logger=logger)
196 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_spinup.SGYREuf"),
197 jn2r(DEST,
"fort.75"),
True,logger=logger)
198 lfile = jn2r(self.
LCDIR,
"hwrf_gfdl_loop_current_rmy5.dat."+y4+mm+dd)
199 rfile = jn2r(self.
LCDIR,
"hwrf_gfdl_loop_current_wc_ring_rmy5.dat."+y4+mm+dd)
200 if Isthis_LCuseful(self.
STARTDATE, lfile, rfile,logger=logger):
201 make_symlink(lfile,jn2r(DEST,
"fort.31"),
True,logger=logger)
202 make_symlink(rfile,jn2r(DEST,
"fort.32"),
True,logger=logger)
204 make_symlink(jn2r(self.
PARMhwrf,
"hwrf_gfdl_loop_current_rmy5.dat"),
205 jn2r(DEST,
"fort.31"),
True,logger=logger)
206 make_symlink(jn2r(self.
PARMhwrf,
"hwrf_gfdl_loop_current_wc_ring_rmy5.dat"),
207 jn2r(DEST,
"fort.32"),
True,logger=logger)
208 inpfile(jn2r(DEST,
"fort.91"), [mm, dd],logger=logger)
209 inpfile(jn2r(DEST,
"input_sharp"),[
"1"],logger=logger)
210 inpfile(jn2r(DEST,
"input"),
212 except Exception
as e:
213 msg=
'Cannot find input: '+str(e)
214 logger.warning(msg,exc_info=
True)
217 """!Runs the FBTR initialization
218 @param DEST the destination directory in which to run and generate output.
219 @param logger a logging.Logger for log messages"""
221 if logger
is None: logger=logging.getLogger(
'pom')
222 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
223 rmall(jn2r(DEST,
"fort.23"),jn2r(DEST,
"fort.74"),jn2r(DEST,
"fort.77"),logger=logger)
224 rmall(jn2r(DEST,
"lonlat.gfs"),jn2r(DEST,
"sst.gfs.dat"),jn2r(DEST,
"mask.gfs.dat"),logger=logger)
225 if os.path.exists(jn2r(DEST,
"fort.11"))
and os.path.exists(jn2r(DEST,
"fort.12")):
226 with open(
'listing',
'wb')
as f:
232 xc = self.conf.getexe(
'hwrf_getsst')
233 log = jn2r(DEST,
"getsst.out")
236 retcode = run(openmp(exe(xc),threads=1).env(OMP_STACKSIZE=
'128M')
238 logger.info(
"hwrf_getsst: err = %s" %(retcode))
239 if retcode == 0
and os.path.exists(jn2r(DEST,
"fort.74")):
240 deliver_file(jn2r(DEST,
"fort.74"),jn2r(DEST,
"sst.gfs.dat"),
False)
241 deliver_file(jn2r(DEST,
"fort.77"),jn2r(DEST,
"mask.gfs.dat"),
False)
242 logger.info(
"GFS SST extracted: {0}".format(DEST))
244 msg=
"hwrf_getsst Failed: NO GFS SST extracted: {0}".format(DEST)
248 msg=
"GFS Spectral Files NOT Found in %s:" %(DEST)
252 if isnonempty(
'fort.31')
and isnonempty(
'fort.32'):
253 rmall(jn2r(DEST,
"fort.13"),jn2r(DEST,
"gfdl_initdata.united."+mm),logger=logger)
254 xc = self.conf.getexe(
'hwrf_sharp_mcs_rf_l2m_rmy5')
255 inp = jn2r(DEST,
"input_sharp")
256 log = jn2r(DEST,
"sharp_mcs_r_l2b.out")
258 retcode = run((exe(xc) < inp) >= log,logger=logger)
259 logger.info(
"sharp_mcs_rf: err = %s" %(retcode))
260 if retcode == 0
and os.path.exists(jn2r(DEST,
"fort.13")):
261 deliver_file(jn2r(DEST,
"fort.13"),jn2r(DEST,
"gfdl_initdata.united."+mm),
False,logger=logger)
262 logger.info(
"Specified LC penetration: {0}".format(retcode))
264 deliver_file(jn2r(self.
FIXhwrf,
"gfdl_initdata.gdem.united."+mm),
265 jn2r(DEST,
"gfdl_initdata.united."+mm),logger=logger)
266 logger.warning(
"sharp_mcs_rf failed: Climate LC penetration %s" %(retcode))
269 deliver_file(jn2r(self.
FIXhwrf,
"gfdl_initdata.gdem.united."+mm),
270 jn2r(DEST,
"gfdl_initdata.united."+mm),logger=logger)
272 logger.critical(
"LC data NOT available: Climate LC penetration %s" %(retcode))
273 if os.path.exists(jn2r(DEST,
"gfdl_initdata.united."+mm)):
274 make_symlink(DEST+
"/gfdl_initdata.united."+mm, DEST+
"/fort.13",
True,logger=logger)
275 xc = self.conf.getexe(
'hwrf_ocean_transatl06prep')
276 log = jn2r(DEST,
"transatl06prep.out")
278 retcode = run(exe(xc) >= log, logger=logger)
279 if retcode == 0
and os.path.exists(jn2r(DEST,
"fort.113")):
280 deliver_file(jn2r(DEST,
"fort.113"),jn2r(DEST,
"gfdl_initdata."+self.
DOMAIN+
"."+mm),
False,logger=logger)
281 logger.info(
"transatl06prep: Success {0}".format(retcode))
283 msg=
"transatl06prep: Failed {0}".format(retcode)
287 logger.info(
"NOT Found in %s:" %(
"gfdl_initdata.united."+mm))
288 if os.path.exists(jn2r(DEST,
"gfdl_initdata."+self.
DOMAIN+
"."+mm)):
289 deliver_file(jn2r(DEST,
"sst.gfs.dat"),jn2r(DEST,
"fort.21"),
False,logger=logger)
290 deliver_file(jn2r(DEST,
"mask.gfs.dat"),jn2r(DEST,
"fort.22"),
False,logger=logger)
291 rmall(jn2r(DEST,
"fort.13"),logger=logger)
292 make_symlink(jn2r(DEST,
"gfdl_initdata."+self.
DOMAIN+
"."+mm),jn2r(DEST,
"fort.13"),
True,logger=logger)
293 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_topo_and_mask."+self.
DOMAIN+
294 ".lores"), jn2r(DEST,
"fort.66"),
True,logger=logger)
295 xc = self.conf.getexe(
"hwrf_ocean_pomprep_"+self.
ODATA[0:2])
296 inp = jn2r(DEST,
"input")
297 log = jn2r(DEST,
"ocean_pomprep.out")
299 retcode = run((exe(xc) < inp ) >= log,logger=logger)
300 if retcode == 0
and os.path.exists(jn2r(DEST,self.
STORMNAME+
".grid.nc")):
301 logger.info(
"ocean_pomprep: Success %s:" %(self.
ODATA))
304 msg=
"ocean_pomprep: Failed %s" %(self.
ODATA)
308 msg=
"NOT Found in %s:" %(
''.join([
"gfdl_initdata.",self.
DOMAIN,
".",mm]))
313 """!Runs the G3 initialization for POM."""
316 @param args,kargs All arguments are passed to Oceanini.__init__()"""
317 super(g3,self).
__init__(*args,**kargs)
319 """!Links all required input files.
320 @param DEST directory in which to link inputs.
321 @param logger a logging.Logger for log messages"""
322 if logger
is None: logger=logging.getLogger(
'pom')
323 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
325 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sfcanl"),jn2r(DEST,
"fort.11"),
True,logger=logger)
326 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sfcanl"),jn2r(DEST,
"for11"),
True,logger=logger)
327 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sanl"),jn2r(DEST,
"fort.12"),
True,logger=logger)
328 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_topo_and_mask."+
329 self.
DOMAIN+
".lores"),jn2r(DEST,
"fort.66"),
True,logger=logger)
330 make_symlink(jn2r(self.
FIXhwrf,
"tgdemv3s"+mm+
".nc"),
331 jn2r(DEST,
"tin.nc"),
True,logger=logger)
332 make_symlink(jn2r(self.
FIXhwrf,
"sgdemv3s"+mm+
".nc"),
333 jn2r(DEST,
"sin.nc"),
True,logger=logger)
334 inpfile(jn2r(DEST,
"input"),
336 except Exception
as e:
337 msg=
'Input Data does NOT exist: %s'%(str(e),)
338 logger.error(msg,exc_info=
True)
341 """!Runs the g3 ocean initialization
342 @param DEST directory in which to run
343 @param logger a logging.Logger for log messages"""
345 if logger
is None: logger=logging.getLogger(
'pom')
346 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
347 rmall(jn2r(DEST,
"fort.23"),jn2r(DEST,
"fort.74"),jn2r(DEST,
"fort.77"),logger=logger)
348 rmall(jn2r(DEST,
"lonlat.gfs"),jn2r(DEST,
"sst.gfs.dat"),jn2r(DEST,
"mask.gfs.dat"),logger=logger)
349 if os.path.exists(jn2r(DEST,
"fort.11"))
and os.path.exists(jn2r(DEST,
"fort.12")):
353 xc = self.conf.getexe(
'hwrf_getsst')
354 log = jn2r(DEST,
"getsst.out")
356 retcode = run(exe(xc).env(OMP_STACKSIZE=
'128M')
358 logger.info(
"hwrf_getsst: err = %s" %(retcode))
359 if retcode == 0
and os.path.exists(jn2r(DEST,
"fort.74")):
360 deliver_file(jn2r(DEST,
"fort.74"),jn2r(DEST,
"sst.gfs.dat"),
False,logger=logger)
361 deliver_file(jn2r(DEST,
"fort.77"),jn2r(DEST,
"mask.gfs.dat"),
False,logger=logger)
362 logger.info(
"GFS SST extracted: {0}".format(retcode))
364 msg=
"hwrf_getsst Failed: NO GFS SST extracted %s" %(retcode)
368 msg=
"GFS Spectral Files NOT Found in %s:" %(DEST)
371 deliver_file(jn2r(DEST,
"sst.gfs.dat"),jn2r(DEST,
"fort.21"),
False,logger=logger)
372 deliver_file(jn2r(DEST,
"mask.gfs.dat"),jn2r(DEST,
"fort.22"),
False,logger=logger)
373 xc = self.conf.getexe(
"hwrf_ocean_pomprep_"+self.
ODATA[0:2])
374 inp = jn2r(DEST,
"input")
375 log = jn2r(DEST,
"ocean_pomprep.out")
377 retcode = run((exe(xc) < inp) > log,logger=logger)
378 if retcode == 0
and os.path.exists(jn2r(DEST,self.
STORMNAME+
".grid.nc")):
379 logging.info(
"ocean_pomprep: Success %s:" %(self.
ODATA))
382 msg=
"ocean_pomprep: Failed %s:" %(self.
ODATA)
387 """!Runs the na (NCODA) initialization of POM."""
390 @param args,kargs All arguments passed to Oceanini.__init__()"""
391 super(na,self).
__init__(*args,**kargs)
393 """!Obtains all input files, linking or copying them.
394 @param DEST Directory in which to link files.
395 @param logger a logging.Logger for log messages"""
396 if logger
is None: logger=logging.getLogger(
'pom')
397 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
400 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sfcanl"),jn2r(DEST,
"fort.11"),
True,logger=logger)
401 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sfcanl"),jn2r(DEST,
"for11"),
True,logger=logger)
402 make_symlink(jn2r(self.
GFSDIR,
"gfs.t"+hh+
"z.sanl"),jn2r(DEST,
"fort.12"),
True,logger=logger)
403 make_symlink(jn2r(self.
FIXhwrf,
"gfdl_ocean_topo_and_mask."+
404 self.
DOMAIN+
".lores"),jn2r(DEST,
"fort.66"),
True,logger=logger)
405 NCDADIR=
"/lfs2/projects/hwrf-vd/hwrf-input/NCODA/"+y4+
"/"+y4+mm+dd+
"/"
406 make_symlink(jn2r(NCDADIR,
"seatmp_pre_000000_005000_1o2161x1051_"+
407 y4+mm+dd+
"00_00000000_analfld"),jn2r(DEST,
"fort.48"),
True,logger=logger)
408 make_symlink(jn2r(NCDADIR,
"salint_pre_000000_005000_1o2161x1051_"+
409 y4+mm+dd+
"00_00000000_analfld"),jn2r(DEST,
"fort.49"),
True,logger=logger)
410 make_symlink(jn2r(self.
FIXhwrf,
"depths_sfc_000000_000000_1o2161x1051_datafld"),
411 jn2r(DEST,
"fort.68"),
True,logger=logger)
412 make_symlink(jn2r(self.
FIXhwrf,
"grdlon_sfc_000000_000000_1o2161x1051_datafld"),
413 jn2r(DEST,
"fort.78"),
True,logger=logger)
414 make_symlink(jn2r(self.
FIXhwrf,
"grdlat_sfc_000000_000000_1o2161x1051_datafld"),
415 jn2r(DEST,
"fort.79"),
True,logger=logger)
417 inpfile(jn2r(DEST,
"input"),
419 except Exception
as e:
420 msg=
'Input data does NOT exist: %s'%(str(e),)
421 logger.error(msg,exc_info=
True)
424 """!Runs the na initialization.
425 @param DEST directory in which to run.
426 @param logger a logging.Logger for log messages."""
428 if logger
is None: logger=logging.getLogger(
'pom')
429 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
430 rmall(jn2r(DEST,
"fort.23"),jn2r(DEST,
"fort.74"),jn2r(DEST,
"fort.77"),logger=logger)
431 rmall(jn2r(DEST,
"lonlat.gfs"),jn2r(DEST,
"sst.gfs.dat"),jn2r(DEST,
"mask.gfs.dat"),logger=logger)
432 if os.path.exists(jn2r(DEST,
"fort.11"))
and os.path.exists(jn2r(DEST,
"fort.12")):
436 xc = self.conf.getexe(
'hwrf_getsst')
437 log = jn2r(DEST,
"getsst.out")
439 retcode = run(exe(xc).env(OMP_STACKSIZE=
'128M')
441 logging.info(
"hwrf_getsst: err = %s" %(retcode))
442 if retcode == 0
and os.path.exists(jn2r(DEST,
"fort.74")):
443 deliver_file(jn2r(DEST,
"fort.74"),jn2r(DEST,
"sst.gfs.dat"),
False,logger=logger)
444 deliver_file(jn2r(DEST,
"fort.77"),jn2r(DEST,
"mask.gfs.dat"),
False,logger=logger)
445 logger.info(
"GFS SST extracted: {0}".format(retcode))
447 msg=
"hwrf_getsst Failed: NO GFS SST extracted %s"%(retcode)
451 msg=
"GFS Spectral Files NOT Found in %s:" %(DEST)
454 deliver_file(jn2r(DEST,
"sst.gfs.dat"),jn2r(DEST,
"fort.21"),
False,logger=logger)
455 deliver_file(jn2r(DEST,
"mask.gfs.dat"),jn2r(DEST,
"fort.22"),
False,logger=logger)
456 xc = self.conf.getexe(
"hwrf_ocean_pomprep_"+self.
ODATA[0:2])
457 inp = jn2r(DEST,
"input")
458 log = jn2r(DEST,
"ocean_pomprep.out")
460 retcode = run((exe(xc) < inp) >log,logger=logger)
461 if retcode == 0
and os.path.exists(jn2r(DEST,self.
STORMNAME+
".grid.nc")):
462 logging.info(
"ocean_pomprep: Success %s:" %(self.
ODATA))
465 msg=
"ocean_pomprep: Failed %s:" %(self.
ODATA)
470 """!Runs a later phase of the ocean init to add additional
471 features such as cold wakes."""
473 """!phase constructor
474 @param args,kargs All arguments are passed to Oceanini.__init__()"""
475 super(phase,self).
__init__(*args,**kargs)
477 """!Links all input data.
478 @param DEST Directory in which to link files.
479 @param logger a logging.Logger for log messages"""
480 if logger
is None: logger=logging.getLogger(
'pom')
482 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
484 make_symlink(jn2r(SRC,self.
STORMNAME+
".grid.nc"),
485 jn2r(DEST,self.
STORMNAME+
".grid.nc"),
True,logger=logger)
486 make_symlink(jn2r(SRC,self.
STORMNAME+
".ts_initial.nc"),
487 jn2r(DEST,self.
STORMNAME+
".ts_initial.nc"),
True,logger=logger)
488 make_symlink(jn2r(SRC,self.
STORMNAME+
".ts_clim.nc"),
489 jn2r(DEST,self.
STORMNAME+
".ts_clim.nc"),
True,logger=logger)
490 make_symlink(jn2r(SRC,self.
STORMNAME+
".uv_initial.nc"),
491 jn2r(DEST,self.
STORMNAME+
".uv_initial.nc"),
True,logger=logger)
492 make_symlink(jn2r(SRC,self.
STORMNAME+
".el_initial.nc"),
493 jn2r(DEST,self.
STORMNAME+
".el_initial.nc"),
True,logger=logger)
494 except Exception
as e:
495 msg=
'Input data does not exist: %s'%(str(e),)
496 logger.warning(msg,exc_info=
True)
500 """!Runs the phase initialization
501 @param DEST The directory in which to run.
502 @param logger A logging.Logger for log messages."""
504 if logger
is None: logger=logging.getLogger(
'pom')
505 (y4,mm,mm1,dd,hh) = ysplitter(self.
STARTDATE)
506 if os.path.exists(jn2r(DEST,self.
STORMNAME+
".grid.nc"))
and \
507 os.path.exists(jn2r(DEST,
"pom.nml")):
508 exe = self.conf.getexe(
"hwrf_ocean_init")
509 log = jn2r(DEST,
"ocean_init.out")
511 retcode=run(mpirun(mpi(exe)*9) >= log ,logger=logger)
512 logger.info(
"hwrf_ocean_init: err = %s" %( retcode))
513 if retcode == 0
and os.path.exists(jn2r(DEST,
"restart.0001.nc")):
514 logger.info(
"Phase completed HERE: %s" %(DEST))
517 msg=
"Phase FAILED HERE: %s" %(DEST)
521 msg=
"Input Files NOT exists %s:" %(DEST)
524 def sendout(self, SRC, infile, DEST, outfile,logger=None):
525 """!Delivers an output file using produtil.fileop.deliver_file()
526 @param SRC Directory with the input file.
527 @param infile Basename of the input file inside of SRC
528 @param DEST Destination directory of the file
529 @param outfile Name of the file in the DEST directory.
530 @param logger A logging.Logger for log messages."""
531 if logger
is None: logger=logging.getLogger(
'pom')
532 if os.path.exists(jn2r(SRC, infile)):
533 deliver_file(jn2r(SRC,infile),jn2r(DEST,outfile),
False,logger=logger)
536 msg=
"Restart file %s does NOT exist:" %(infile)
541 """!Utility class for obtaining input data."""
542 def getinp(self, this, DEST,logger=None):
543 """!Asks "this" to deliver its input by calling this.getinp(...)
544 @param this an Oceanini object
545 @param DEST directory in which to make links
546 @param logger a logging.Logger for messages"""
547 if logger
is None: logger=logging.getLogger(
'pom')
548 logger.info(
'get input this=%s DEST=%s'%(repr(this),repr(DEST)))
549 this.getinp(DEST,logger=logger)
551 """!Utility class for executing ocean initialization setrun functions."""
552 def setrun(self, this, DEST,logger=None):
553 """!Runs this.setrun(...) to run the ocean initialization
554 @param this an Oceanini object
555 @param DEST the directory in which to run
556 @param logger a logging.Logger for log messages"""
557 if logger
is None: logger=logging.getLogger(
'pom')
558 return this.setrun(DEST, logger=logger)
560 """!Utility class for delivering Oceanini output."""
561 def sendout(self, this, SRC, infile, DEST, outfile, logger=None):
562 """!Calls this.sendout(...)
563 @param this An Oceanini object.
564 @param SRC the directory from which to copy
565 @param infile the input file basename of the file in SRC
566 @param DEST the destination directory
567 @param outfile the name of the output file in DEST
568 @param logger a logging.Logger for log messages"""
569 if logger
is None: logger=logging.getLogger(
'pom')
570 return this.sendout(SRC, infile, DEST, outfile, logger=logger)
STORMID
Three character storm number and basin, upper-case (12L)
Change directory, handle temporary directories.
This module provides a set of utility functions to do filesystem operations.
Runs the na (NCODA) initialization of POM.
def __init__(self, args, kargs)
na Constructor
Imitates the shell "ls -l" program.
STORMNAME
Upper-case storm name for filenames (KATRINA)
def setpath
Creates the ocean run path, whose subdirectory is SUBDIR.
def setrun
Runs this.setrun(...) to run the ocean initialization.
PARMhwrf
Directory with HWRF parameter files.
EXEChwrf
Directory with HWRF executables.
def setrun
Runs the g3 ocean initialization.
GFSDIR
Directory with input files from GFS.
Runs the G3 initialization for POM.
Utility class for delivering Oceanini output.
def __init__(self, args, kargs)
phase constructor
Parent class of POM initialization classes.
def __init__(self, ODIR, DOMAIN, ODATA, SSTASIM, STORMNAME, STORMID, STARTDATE, EXEChwrf, PARMhwrf, FIXhwrf, LCDIR, GFSDIR, CSTREAM, COMIN, sync_frequently=False, kwargs)
Oceanini constructor.
def getrlimit
Gets the current resource limits.
def getinp
Asks "this" to deliver its input by calling this.getinp(...)
def getinp
Obtains all input files, linking or copying them.
def setrun
Runs the phase initialization.
def __init__
Hwrf constructor.
ODIR
Ocean output directory in CSTREAM.
Raised when the init has trouble extracting SSTs.
SSTASIM
SST ASIM flag, True or False.
A shell-like syntax for running serial, MPI and OpenMP programs.
def setrun
Runs the FBTR initialization.
def getinp
Links or copies input files.
This subclass of TempDir takes a directory name, instead of generating one automatically.
This module allows querying resource usage and limits, as well as setting resource limits...
def setrun
Runs the na initialization.
def getinp
Links all input data.
def __init__(self, args, kargs)
g3 constructor
FIXhwrf
Directory with HWRF fixed files.
COMIN
HWRF final output directory.
Runs a later phase of the ocean init to add additional features such as cold wakes.
Utility class for obtaining input data.
conf
A ConfigParser-like object to use for configuration information.
rusage
Alias for produtil.rusage.RUsage.
def sendout
Calls this.sendout(...)
STARTDATE
Simulation analysis time as a string, YYYYMMDDHH (2005082918)
def sendout
Delivers an output file using produtil.fileop.deliver_file()
Abstract base class that stores data relating to the HWRF workflow in which the POM initialization re...
LCDIR
Directory with loop current files.
CSTREAM
Directory to place files for the POM forecast to read.
def __init__(self, args, kargs)
fbtr constructor
Utility class for executing ocean initialization setrun functions.
def setrlimit(logger=None, ignore=False, hard=False, kwargs)
Sets resource limits.
Raised when a POM initialization program unexpectedly fails.
Runs the FBTR (feature-based) initialization of the MPIPOMTC.
def getinp
Links all required input files.
Raised when the POM prep fails.