HWRF  trunk@4391
psychoanalyst.py
1 #! /usr/bin/env python
2 
3 ##@namespace ush.psychoanalyst
4 #
5 #This script runs all HWRF sanity checks that do not require a
6 #specific cyle to run. These are the same sanity checks run by the
7 #Rocoto automation system in rocoto/run_hwrf.py, except that no cycles
8 #are started. Call like so:
9 # @code{.sh}
10 # psychoanalyst.py 18L HISTORY [conf files] [option arguments]
11 # @endcode
12 #
13 # Where:
14 # * 18L --- the three character storm ID
15 # * HISTORY --- HISTORY for a retrospective run, FORECAST for a real-time run
16 # * [conf files] --- a list of configuration files to read after
17 # reading standard configuration files.
18 # * [option arguments] --- a list of section.Option=VALUE
19 # configuration settings to set after reading configuration files
20 #
21 # See the hwrf.launcher module for more details on the launching process and
22 # the sanity checks.
23 import os, logging,sys
24 
25 def main():
26  if os.path.isdir('ush'):
27  sys.path.append(os.path.realpath('ush'))
28 
29  import produtil.setup
30  import hwrf.launcher
31 
32  def usage(message=None,logger=None):
33  print>>sys.stderr, '''Sanity check failed: incorrect arguments:
34  psychoanalyst.py 18L HISTORY [conf files] [option arguments]
35 
36  [conf files] - paths to *.conf files to parse after standard ones
37  [option arguments] - section.option=value arguments to set configuration
38  options in individual sections'''
39  if message is not None:
40  logger.error('parse_launch_args says this: %s'%(str(message),))
41 
42  produtil.setup.setup(send_dbn=False)
43 
44  logger=logging.getLogger('hwrf.psychoanalyst')
45  logger.info('HWRF Psychoanalyst: running HWRF sanity checks.')
46 
47  if os.path.isdir('../parm'):
48  PARMhwrf=os.path.realpath('../parm')
49  logger.info('Assuming PARMhwrf = ../parm = %s'%(PARMhwrf,))
50  elif os.path.isdir('parm'):
51  PARMhwrf=os.path.realpath('parm')
52  logger.info('Assuming PARMhwrf = parm = %s'%(PARMhwrf,))
53  else:
54  logger.error('Cannot guess PARMhwrf path. You should run this program from the ush directory or the directory above it.')
55 
56  logger.info('Telling the hwrf.launcher to parse %s'%(' '.join(sys.argv[1:])))
57 
58  (case_root,parm,infiles,stid,moreopt)=\
60  sys.argv[1:],logger,usage,PARMhwrf=PARMhwrf)
61 
62  logger.info('Calling hwrf.launcher.launch...')
63  conf=hwrf.launcher.launch(infiles,None,stid,moreopt,case_root,init_dirs=False)
64 
65  logger.info('Run sanity checks.')
66  try:
67  conf.timeless_sanity_check(logger=logger)
68  except Exception as e:
69  logger.info(str(e),exc_info=True)
70  print '\n\n'
71  logger.info('''Sanity check failed.
72 
73  Error message is: %s
74 
75  See earlier messages for details. Checklist for common errors:
76 
77  1. Did you link the fix files?
78  2. Does your config.EXPT value match the installation directory name?
79  3. Did you run "make" and "make install" in the sorc directory?
80  4. Did you build and install, or link, the exec/hwrf_gsi?
81 
82  The HWRF Psychoanalyist pronounces you insane. Fix problems and try again.'''
83  %(str(e),))
84  sys.exit(1)
85 
86  logger.info('Done. The HWRF Psychoanalyst pronounces you sane.')
87 
88 if __name__=='__main__': main()
Contains setup(), which initializes the produtil package.
Definition: setup.py:1
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
def parse_launch_args
Parsed arguments to scripts that launch the HWRF system.
Definition: launcher.py:170
def launch
Initializes the directory structure for a new HWRF workflow.
Definition: launcher.py:404
Creates the initial HWRF directory structure, loads information into each job.
Definition: launcher.py:1