Skip to content

Commit

Permalink
Move analysis post to new stand-alone task (#1979)
Browse files Browse the repository at this point in the history
This PR addresses issue #1130. A new task `postanl.sh` has been added such that the
`anl` post-processing is not it's own task within the Rocoto workflow. This change
prevents the GDAS experiment from breaking due to failures caused by the `anl` not
being available for the first cycle.

Resolves #1130
  • Loading branch information
HenryRWinterbottom authored Nov 2, 2023
1 parent 247cdf8 commit 31b05a9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 35 deletions.
12 changes: 0 additions & 12 deletions jobs/JGLOBAL_ATMOS_POST
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ export g2tmpl_ver=${g2tmpl_ver:-v1.5.0}
##############################################
export CDUMP=${RUN/enkf}


##############################################
# TODO: Remove this egregious HACK
##############################################
if [[ "${SDATE:-}" = "${PDY}${cyc}" ]]; then
if [[ ${post_times} = "anl" ]]; then
echo "No offline post-processing in the first half cycle for analysis"
exit 0
fi
fi


##############################################
# Begin JOB SPECIFIC work
##############################################
Expand Down
7 changes: 1 addition & 6 deletions jobs/rocoto/post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ source "${HOMEgfs}/ush/preamble.sh"

###############################################################
## NCEP post driver script
## FHRGRP : forecast hour group to post-process (e.g. 0, 1, 2 ...)
## FHRLST : forecast hourlist to be post-process (e.g. anl, f000, f000_f001_f002, ...)
###############################################################

Expand All @@ -16,11 +15,7 @@ status=$?
export job="post"
export jobid="${job}.$$"

if [ ${FHRGRP} = 'anl' ]; then
fhrlst="anl"
else
fhrlst=$(echo ${FHRLST} | sed -e 's/_/ /g; s/f/ /g; s/,/ /g')
fi
fhrlst=$(echo ${FHRLST} | sed -e 's/_/ /g; s/f/ /g; s/,/ /g')

#---------------------------------------------------------------
for fhr in ${fhrlst}; do
Expand Down
1 change: 1 addition & 0 deletions jobs/rocoto/postanl.sh
2 changes: 1 addition & 1 deletion workflow/applications/gfs_cycled.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_task_names(self):
"""

gdas_gfs_common_tasks_before_fcst = ['prep']
gdas_gfs_common_tasks_after_fcst = ['post']
gdas_gfs_common_tasks_after_fcst = ['postanl', 'post']
# if self.do_ocean: # TODO: uncomment when ocnpost is fixed in cycled mode
# gdas_gfs_common_tasks_after_fcst += ['ocnpost']
gdas_gfs_common_tasks_after_fcst += ['vrfy']
Expand Down
2 changes: 1 addition & 1 deletion workflow/hosts/awspw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ LOCALARCH: 'NO'
ATARDIR: '/NCEPDEV/${HPSS_PROJECT}/1year/${USER}/${machine}/scratch/${PSLOT}' # TODO: This will not yet work from AWS.
MAKE_NSSTBUFR: 'NO'
MAKE_ACFTBUFR: 'NO'
SUPPORTED_RESOLUTIONS: ['C48'] # TODO: Test and support all cubed-sphere resolutions.
SUPPORTED_RESOLUTIONS: ['C48', 'C96'] # TODO: Test and support all cubed-sphere resolutions.
40 changes: 25 additions & 15 deletions workflow/rocoto/gfs_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,24 +549,37 @@ def _fcst_cycled(self):
return task

def post(self):
add_anl_to_post = False
if self.app_config.mode in ['cycled']:
add_anl_to_post = True
return self._post_task('post')

def postanl(self):
postenvars = self.envars.copy()
postenvar_dict = {'FHRLST': 'anl',
'ROTDIR': self._base.get('ROTDIR')}

for key, value in postenvar_dict.items():
postenvars.append(rocoto.create_envar(name=key, value=str(value)))

return self._post_task('post', add_anl_to_post=add_anl_to_post)
deps = []
atm_anl_path = self._template_to_rocoto_cycstring(self._base["COM_ATMOS_ANALYSIS_TMPL"])
data = f'{atm_anl_path}/{self.cdump}.t@Hz.loganl.txt'
dep_dict = {'type': 'data', 'data': data}
deps.append(rocoto.add_dependency(dep_dict))
dependencies = rocoto.create_dependency(dep=deps)
resources = self.get_resource('post')
task = create_wf_task('postanl', resources, cdump=self.cdump, envar=postenvars, dependency=dependencies,
cycledef=self.cdump)

return task

def ocnpost(self):
if self.app_config.mode in ['forecast-only']: # TODO: fix ocnpost in cycled mode
return self._post_task('ocnpost', add_anl_to_post=False)
return self._post_task('ocnpost')

def _post_task(self, task_name, add_anl_to_post=False):
def _post_task(self, task_name):
if task_name not in ['post', 'ocnpost']:
raise KeyError(f'Invalid post-processing task: {task_name}')

if task_name in ['ocnpost']:
add_anl_to_post = False

def _get_postgroups(cdump, config, add_anl=False):
def _get_postgroups(cdump, config):

fhmin = config['FHMIN']
fhmax = config['FHMAX']
Expand All @@ -591,8 +604,6 @@ def _get_postgroups(cdump, config, add_anl=False):
fhrs = [f'f{fhr:03d}' for fhr in fhrs]
fhrs = np.array_split(fhrs, ngrps)
fhrs = [fhr.tolist() for fhr in fhrs]
if add_anl:
fhrs.insert(0, ['anl'])

grp = ' '.join(f'_{fhr[0]}-{fhr[-1]}' if len(fhr) > 1 else f'_{fhr[0]}' for fhr in fhrs)
dep = ' '.join([fhr[-1] for fhr in fhrs])
Expand All @@ -610,14 +621,13 @@ def _get_postgroups(cdump, config, add_anl=False):
dependencies = rocoto.create_dependency(dep_condition='or', dep=deps)

postenvars = self.envars.copy()
postenvar_dict = {'FHRGRP': '#grp#',
'FHRLST': '#lst#',
postenvar_dict = {'FHRLST': '#lst#',
'ROTDIR': self._base.get('ROTDIR')}
for key, value in postenvar_dict.items():
postenvars.append(rocoto.create_envar(name=key, value=str(value)))

varname1, varname2, varname3 = 'grp', 'dep', 'lst'
varval1, varval2, varval3 = _get_postgroups(self.cdump, self._configs[task_name], add_anl=add_anl_to_post)
varval1, varval2, varval3 = _get_postgroups(self.cdump, self._configs[task_name])
vardict = {varname2: varval2, varname3: varval3}

cycledef = 'gdas_half,gdas' if self.cdump in ['gdas'] else self.cdump
Expand Down

0 comments on commit 31b05a9

Please sign in to comment.