Skip to content

Commit

Permalink
Move NET/MODE options to _get_run_options
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHuber-NOAA committed Oct 16, 2024
1 parent 2e92009 commit daecdc9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 39 deletions.
32 changes: 4 additions & 28 deletions workflow/applications/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ def _init_finalize(self, conf: Configuration):
for run in self.runs:
self.configs[run] = self._source_configs(conf, run=run, log=False)

@abstractmethod
def _get_run_options(self, conf: Configuration) -> Dict[str, Any]:
'''
Determine the do_* and APP options for each RUN by sourcing config.base
for each RUN and collecting the flags into self.run_options
for each RUN and collecting the flags into self.run_options. Note that
this method is overloaded so additional NET- and MODE-dependent flags
can be set.
'''

run_options = {run: {} for run in dict.fromkeys(self.runs)}
Expand Down Expand Up @@ -96,7 +99,6 @@ def _get_run_options(self, conf: Configuration) -> Dict[str, Any]:
run_options[run]['do_wave'] = run_base.get('DO_WAVE', False)
run_options[run]['do_ocean'] = run_base.get('DO_OCN', False)
run_options[run]['do_ice'] = run_base.get('DO_ICE', False)
run_options[run]['do_aero'] = run_base.get('DO_AERO', False)
run_options[run]['do_prep_obs_aero'] = run_base.get('DO_PREP_OBS_AERO', False)
run_options[run]['do_aero_anl'] = run_base.get('DO_AERO_ANL', False)
run_options[run]['do_aero_fcst'] = run_base.get('DO_AERO_FCST', False)
Expand All @@ -107,35 +109,9 @@ def _get_run_options(self, conf: Configuration) -> Dict[str, Any]:
if not AppConfig.is_monotonic(run_options[run]['fcst_segments']):
raise ValueError(f'Forecast segments do not increase monotonically: {",".join(self.fcst_segments)}')

# Append any MODE-specific options
run_options = self._netmode_run_options(run_base, run_options)

# Return the dictionary of run options
return run_options

@abstractmethod
def _netmode_run_options(self, base: Dict[str, Any], run_options: Dict[str, Any]) -> Dict[str, Any]:
'''
Defines run-based options for a given NET_MODE case.
Parameters
----------
base: Dict
Parsed config.base settings
run_options: Dict
A dictionary with valid RUN-based sub-dictionaries containing generic options.
Returns
-------
run_options: Dict
Output dictionary with additional options valid for the given NET and MODE.
'''

# Valid NET_MODE options are defined in the appropriate subclass.

pass

@abstractmethod
def _get_app_configs(self):
pass
Expand Down
11 changes: 7 additions & 4 deletions workflow/applications/gefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ def __init__(self, conf: Configuration):
self.run = base.get('RUN', 'gefs')
self.runs = [self.run]

def _netmode_run_options(self, base: Dict[str, Any], run_options: Dict[str, Any]) -> Dict[str, Any]:
def _get_run_options(self, conf: Configuration) -> Dict[str, Any]:

run_options = super()._get_run_options(conf)

run_options[self.run]['nens'] = conf.parse_config('config.base').get('NMEM_ENS', 0)

run_options[self.run]['nens'] = base.get('NMEM_ENS', 0)
return run_options

def _get_app_configs(self, run):
Expand All @@ -38,7 +41,7 @@ def _get_app_configs(self, run):
if options['do_ocean'] or options['do_ice']:
configs += ['oceanice_products']

if options['do_aero']:
if options['do_aero_fcst']:
configs += ['prep_emissions']

if options['do_extractvars']:
Expand All @@ -63,7 +66,7 @@ def get_task_names(self):
if options['do_wave']:
tasks += ['waveinit']

if options['do_aero']:
if options['do_aero_fcst']:
tasks += ['prep_emissions']

tasks += ['fcst']
Expand Down
8 changes: 6 additions & 2 deletions workflow/applications/gfs_cycled.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ def __init__(self, conf: Configuration):
self.runs.append("gfs") if base['gfs_cyc'] > 0 else 0
self.runs.append('enkfgfs') if 'gfs' in self.ens_runs and "gfs" in self.runs else 0

def _netmode_run_options(self, base: Dict[str, Any], run_options: Dict[str, Any]) -> Dict[str, Any]:
def _get_run_options(self, conf: Configuration) -> Dict[str, Any]:

run_options = super()._get_run_options(conf)

for run in self.runs:
base = conf.parse_config('config.base', RUN=run)

run_options[run]['do_hybvar'] = base.get('DOHYBVAR', False)
run_options[run]['nens'] = base.get('NMEM_ENS', 0)
if run_options[run]['do_hybvar']:
Expand Down Expand Up @@ -126,7 +130,7 @@ def _get_app_configs(self, run):
if options['do_awips']:
configs += ['waveawipsbulls', 'waveawipsgridded']

if options['do_aero']:
if options['do_aero_anl']:
configs += ['aeroanlgenb', 'aeroanlinit', 'aeroanlvar', 'aeroanlfinal']
if options['do_prep_obs_aero']:
configs += ['prepobsaero']
Expand Down
8 changes: 5 additions & 3 deletions workflow/applications/gfs_forecast_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ def __init__(self, conf: Configuration):
self.run = base.get('RUN', 'gfs')
self.runs = [self.run]

def _netmode_run_options(self, base: Dict[str, Any], run_options: Dict[str, Any]) -> Dict[str, Any]:
def _get_run_options(self, conf: Configuration) -> Dict[str, Any]:

run_options[self.run]['exp_warm_start'] = base.get('EXP_WARM_START', False)
run_options = super()._get_run_options(conf)

run_options[self.run]['exp_warm_start'] = conf.parse_config('config.base').get('EXP_WARM_START', False)

return run_options

Expand All @@ -36,7 +38,7 @@ def _get_app_configs(self, run):

configs += ['atmos_products']

if options['do_aero']:
if options['do_aero_fcst']:
if not options['exp_warm_start']:
configs += ['aerosol_init']

Expand Down
4 changes: 2 additions & 2 deletions workflow/rocoto/gefs_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def fcst(self):
dep_dict = {'type': 'task', 'name': f'gefs_wave_init'}
dependencies.append(rocoto.add_dependency(dep_dict))

if self.options['do_aero']:
if self.options['do_aero_fcst']:
dep_dict = {'type': 'task', 'name': f'gefs_prep_emissions'}
dependencies.append(rocoto.add_dependency(dep_dict))

Expand Down Expand Up @@ -114,7 +114,7 @@ def efcs(self):
dep_dict = {'type': 'task', 'name': f'gefs_wave_init'}
dependencies.append(rocoto.add_dependency(dep_dict))

if self.options['do_aero']:
if self.options['do_aero_fcst']:
dep_dict = {'type': 'task', 'name': f'gefs_prep_emissions'}
dependencies.append(rocoto.add_dependency(dep_dict))

Expand Down

0 comments on commit daecdc9

Please sign in to comment.