HWRF  trunk@4391
exhwrf_gsi.py
1 #! /usr/bin/env python
2 
3 ##@namespace scripts.exhwrf_gsi
4 #Runs the GSI data assimilation system scripts in hwrf.gsi on one
5 #of the HWRF resolutions. The resolution is selected by the
6 #$GSI_DOMAIN environment variable:
7 #
8 #* $GSI_DOMAIN=d02 --- run the intermediate resolution GSI
9 #* $GSI_DOMAIN=d03 --- run the innermost domain GSI
10 
11 ## List of symbols exported by "from exhwrf_gsi import *"
12 __all__=[]
13 import logging
15 from produtil.log import jlogger
16 import hwrf_wcoss
17 import hwrf.gsi
18 
19 def fail(msg):
20  """!Logs a message to the produtil.log.jlogger and exits with status 2
21  @param msg the error message"""
22  jlogger.error(msg)
23  sys.exit(2)
24 
25 def main():
26  """!Runs the selected GSI task."""
27  ENV=os.environ
28  gsi_domain=ENV['GSI_DOMAIN'].lower()
29  if gsi_domain!='d02' and gsi_domain!='d03':
30  fail('Aborting: gsi_domain="%s" must be "d02" or "d03"'%(gsi_domain,))
31 
32  import hwrf_expt
34  logger=hwrf_expt.conf.log('exhwrf_gsi')
35 
36  if not hwrf_expt.conf.getbool('config','run_gsi'):
37  jlogger.info('GSI is disabled. This job need not be run.')
38  sys.exit(0)
39 
40  if produtil.cluster.name() in ['gyre','tide']:
42  else:
43  logger.info('Not on WCOSS, so not setting WCOSS-specific vars.')
44 
45  if not hwrf.gsi.get_gsistatus(hwrf_expt.conf,'gsi_'+gsi_domain,logger):
46  jlogger.info('GSI is disabled for %s. This job need not be run.'
47  %(gsi_domain,))
48  sys.exit(0)
49  else:
50  logger.info('GSI is enabled for %s.'%(gsi_domain,))
51 
52  if gsi_domain=='d02':
53  hwrf_expt.gsi_d02.run()
54  else:
55  hwrf_expt.gsi_d03.run()
56 
57 if __name__=='__main__':
58  try:
59  produtil.setup.setup(thread_logger=True,eloglevel=logging.INFO)
60  main()
61  except Exception as e:
62  jlogger.critical('HWRF GSI is aborting: '+str(e),exc_info=True)
63  sys.exit(2)
Contains setup(), which initializes the produtil package.
Definition: setup.py:1
def fail(msg)
Logs a message to the produtil.log.jlogger and exits with status 2.
Definition: exhwrf_gsi.py:19
def init_module
Initializes the HWRF object structure.
Definition: hwrf_expt.py:384
def get_gsistatus
Checks the gsi status for a specific domain.
Definition: gsi.py:1273
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
Runs the GSI data assimilation on the HWRF system.
Definition: gsi.py:1
Provides information about the cluster on which this job is running.
Definition: cluster.py:1
def main()
Runs the selected GSI task.
Definition: exhwrf_gsi.py:25
Configures logging.
Definition: log.py:1
def name()
Synonym for here.name.
Definition: cluster.py:109
def set_vars_for_gsi(logger)
Set variables for running GSI quickly on WCOSS.
Definition: hwrf_wcoss.py:117