HWRF  trunk@4391
exhwrf_ocean_init.py
1 #! /usr/bin/env python
2 
3 ##@namespace scripts.exhwrf_ocean_init
4 # Runs the ocean initialization for the chosen ocean model and sets
5 # the ocean status file accordingly. Does nothing if ocean is disabled
6 # via [config] run_ocean=no
7 
8 import os, sys
10 import pom.exceptions
12 from produtil.log import jlogger
13 
14 def main():
15  """!Runs the ocean initialization and sets the ocean status file."""
16  import hwrf_expt
18  conf=hwrf_expt.conf
19  ocean=conf.getstr('config','ocean_model')
20  logger=conf.log('exhwrf_ocean_init')
21  ocstatus=hwrf_expt.ocstatus
22  ocstatus.unset(logger)
23  try:
24  if not conf.getbool('config','run_ocean'):
25  jlogger.info('Ocean is disabled. This job need not be run.')
26  ocstatus.set(False,logger)
27  return
28  if ocean=='POM':
29  hwrf_expt.pominit.run()
30  ocstatus.set(True,logger)
31  elif ocean=='HYCOM':
32  hi=hwrf_expt.hycominit
33  hi.run()
34  hi.fill_ocstatus(ocstatus,logger)
35  else:
36  jlogger.critical('Config file error: unsupported ocean model '
37  '%s. Will run without ocean.'%(repr(ocean),))
38  ocstatus.set(False,logger)
40  produtil.log.postmsg('Unsupported basin: will run without ocean.')
41  ocstatus.set(False,logger)
42  return
43  except Exception as e:
44  if conf.getbool('config','allow_fallbacks',False):
45  logger.error('Could not run ocean init: will run without ocean.'
46  ' Unhandled exception: '+str(e),exc_info=True)
47  ocstatus.set(False,logger)
48  return
49  raise
50 
51 if __name__=='__main__':
52  try:
54  main()
55  except Exception as e:
56  jlogger.critical('HWRF Ocean Initialization is aborting: '
57  +str(e),exc_info=True)
58  sys.exit(2)
Runs the POM initialization and POM-WRF coupled forecast.
Definition: mpipomtc.py:1
Contains setup(), which initializes the produtil package.
Definition: setup.py:1
def init_module
Initializes the HWRF object structure.
Definition: hwrf_expt.py:384
def postmsg(message)
Sends the message to the jlogfile logging stream at level INFO.
Definition: log.py:46
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.
Definition: setup.py:15
Raised when an unsupported basin is requested.
Definition: exceptions.py:32
def main()
Runs the ocean initialization and sets the ocean status file.
Configures logging.
Definition: log.py:1
This module contains exception classes for reporting errors in the POM initialization.
Definition: exceptions.py:1