Skip to content

Commit

Permalink
Remove f000 from atmos rocoto tasks for replay cases (#2778)
Browse files Browse the repository at this point in the history
The main purpose of this PR is to remove the f000 from
atmosphere-related rocoto tasks when `REPLAY_ICS` is set to `YES`. In
cases where `REPLAY_ICS` is `YES` and `OFFSET_START_HOUR `is greater
than `0`, it becomes necessary to have the first lead hour set to
`OFFSET_START_HOUR ` for the atmosphere-related rocoto tasks. For
example, when `OFFSET_START_HOUR ` is set to `3`, then the minimum lead
time for the atmos_prod and atmos_ensstat rocoto tasks needs to be 3 and
the minimum lead time for the ocean_prod rocoto task needs to be 6
(assuming `FHOUT_OCN` is 6). This PR makes this rocoto workflow set up
possible by removing 0 from fhrs for atmosphere-related tasks in
`gefs_tasks.py` when replaying.

This PR also moves where f000 is being removed for the ocean_prod and
ice_prod tasks. The if-block that performs this f000 removal has been
moved from `tasks.py` to `gefs_tasks.py` and `gfs_tasks.py`.

---------

Co-authored-by: Rahul Mahajan <[email protected]>
  • Loading branch information
EricSinsky-NOAA and aerorahul authored Jul 29, 2024
1 parent f156a78 commit 61875f2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions scripts/exglobal_stage_ic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ for MEMDIR in "${MEMDIR_ARRAY[@]}"; do

# Atmosphere Perturbation Files (usually used with replay ICS)
# Extra zero on MEMDIR ensure we have a number even if the string is empty
if (( 0${MEMDIR:3} > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then
if (( $((10#0${MEMDIR:3})) > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then
YMD=${PDY} HH=${cyc} declare_from_tmpl COM_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL
[[ ! -d "${COM_ATMOS_ANALYSIS}" ]] && mkdir -p "${COM_ATMOS_ANALYSIS}"
src="${BASE_CPLIC}/${CPL_ATMIC:-}/${PDY}${cyc}/${MEMDIR}/atmos/${DTG_PREFIX}.fv3_perturbation.nc"
Expand Down Expand Up @@ -130,7 +130,7 @@ for MEMDIR in "${MEMDIR_ARRAY[@]}"; do

# Ocean Perturbation Files
# Extra zero on MEMDIR ensure we have a number even if the string is empty
if (( 0${MEMDIR:3} > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then
if (( $((10#0${MEMDIR:3})) > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then
YMD=${PDY} HH=${cyc} declare_from_tmpl COM_OCEAN_ANALYSIS:COM_OCEAN_ANALYSIS_TMPL
[[ ! -d "${COM_OCEAN_ANALYSIS}" ]] && mkdir -p "${COM_OCEAN_ANALYSIS}"
src="${BASE_CPLIC}/${CPL_OCNIC:-}/${PDY}${cyc}/${MEMDIR}/ocean/${DTG_PREFIX}.mom6_perturbation.nc"
Expand Down
16 changes: 16 additions & 0 deletions workflow/rocoto/gefs_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ def _atmosoceaniceprod(self, component: str):
'maxtries': '&MAXTRIES;'}

fhrs = self._get_forecast_hours('gefs', self._configs[config], component)

# when replaying, atmos component does not have fhr 0, therefore remove 0 from fhrs
is_replay = self._configs[config]['REPLAY_ICS']
if is_replay and component in ['atmos'] and 0 in fhrs:
fhrs.remove(0)

# ocean/ice components do not have fhr 0 as they are averaged output
if component in ['ocean', 'ice'] and 0 in fhrs:
fhrs.remove(0)

fhr_var_dict = {'fhr': ' '.join([f"{fhr:03d}" for fhr in fhrs])}

fhr_metatask_dict = {'task_name': f'{component}_prod_#member#',
Expand Down Expand Up @@ -314,6 +324,12 @@ def atmos_ensstat(self):
'maxtries': '&MAXTRIES;'}

fhrs = self._get_forecast_hours('gefs', self._configs['atmos_ensstat'])

# when replaying, atmos component does not have fhr 0, therefore remove 0 from fhrs
is_replay = self._configs['atmos_ensstat']['REPLAY_ICS']
if is_replay and 0 in fhrs:
fhrs.remove(0)

fhr_var_dict = {'fhr': ' '.join([f"{fhr:03d}" for fhr in fhrs])}

fhr_metatask_dict = {'task_name': f'atmos_ensstat',
Expand Down
5 changes: 5 additions & 0 deletions workflow/rocoto/gfs_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,11 @@ def _atmosoceaniceprod(self, component: str):
}

fhrs = self._get_forecast_hours(self.cdump, self._configs[config], component)

# ocean/ice components do not have fhr 0 as they are averaged output
if component in ['ocean', 'ice'] and 0 in fhrs:
fhrs.remove(0)

fhr_var_dict = {'fhr': ' '.join([f"{fhr:03d}" for fhr in fhrs])}
metatask_dict = {'task_name': f'{self.cdump}{component}_prod',
'task_dict': task_dict,
Expand Down
4 changes: 0 additions & 4 deletions workflow/rocoto/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ def _get_forecast_hours(cdump, config, component='atmos') -> List[str]:
fhrs_hf = range(fhmin, fhmax_hf + fhout_hf, fhout_hf)
fhrs = list(fhrs_hf) + list(range(fhrs_hf[-1] + fhout, fhmax + fhout, fhout))

# ocean/ice components do not have fhr 0 as they are averaged output
if component in ['ocean', 'ice'] and 0 in fhrs:
fhrs.remove(0)

return fhrs

def get_resource(self, task_name):
Expand Down

0 comments on commit 61875f2

Please sign in to comment.